Repository navigation
docs(response): require a usable default on every required response field - #14366
Conversation
…ield SDK models fill a field an older server does not send from its spec default, so a required field with none makes every older server's response unreadable for that model. The test builds the spec for every registered model and fails on a required scalar property without a default. The 80 existing gaps are recorded in a baseline that must shrink as they are fixed. AuthProvider.enabled, Embedding.model, Embedding.dimension and JWT.jwt had no default at all and now do.
|
Review complete. No blocking issues — 3 nitpicks below. 🧹 Nitpicks (3) — 🟢 3 low
The PR introduces three new Utopia response models (
Reviewed commit: 40e1928 |
🔵 Tier A · Mergeable after minor fixes
Documents that required response-model fields need schema-accepted defaults, and adds defaults to Latest changes: The newest commit removes the model-defaults unit test and baseline and removes its enforcement link from
Fix with agent prompt### Issue 1
AGENTS.md:290
**Keep coverage for generated response defaults**
The latest commit removes the only test that checked required response fields against generated-spec defaults, leaving these new defaults without a regression check. The nearby response-model tests cover filtering and requiredness, but not whether defaults remain present in the generated spec, so a future regression could break SDK fallback unnoticed.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.📂 Walkthrough · 6
Reviewed the commits since |
| - **Collections:** lowercase plural. Attributes camelCase; do not prefix with the collection name. `resourceType` is usually plural (`functions`, `sites`, `deployments`). | ||
| - **DI:** inject object dependencies only (`$dbForProject`, `$queueForEvents`, `$user`). `{role}For{Target}` only when multiple of that role coexist (`dbForProject` / `dbForPlatform`). Register new resources in `app/init/resources.php` and `app/init/resources/request.php`. Never inject callbacks or global-shaped functions to reuse logic — see [Reuse](#reuse). | ||
| - **Models:** class PascalCase; `getName()` matches. `Response::MODEL_*` constants `SCREAMING_SNAKE_CASE`; values camelCase singular (`team`) or `{name}List`. | ||
| - **Models:** class PascalCase; `getName()` matches. `Response::MODEL_*` constants `SCREAMING_SNAKE_CASE`; values camelCase singular (`team`) or `{name}List`. A required rule needs a `default` its schema accepts (an enum member, an array for an array rule), because SDK models fill a field an older server does not send from it; without one, make the rule `required => false`. |
There was a problem hiding this comment.
Keep coverage for generated response defaults
The latest commit removes the only test that checked required response fields against generated-spec defaults, leaving these new defaults without a regression check. The nearby response-model tests cover filtering and requiredness, but not whether defaults remain present in the generated spec, so a future regression could break SDK fallback unnoticed.
Prompt To Fix With AI
This is a comment left during a code review.
Path: AGENTS.md
Line: 290
Comment:
**Keep coverage for generated response defaults**
The latest commit removes the only test that checked required response fields against generated-spec defaults, leaving these new defaults without a regression check. The nearby response-model tests cover filtering and requiredness, but not whether defaults remain present in the generated spec, so a future regression could break SDK fallback unnoticed.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.🟡 Minor · testing · Reply if this doesn't apply.
Security rulesNo new WARNING or ERROR findings from security rules. 32 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Documents the convention that every required response field has a usable default, and adds defaults to the four required fields that had none.
Why
#14357 put response-model defaults into the spec. appwrite/sdk-generator#2005 makes every SDK fill a missing field from that default instead of failing. That's how sdk-for-php 28+ can read
File.folderfrom a 1.x server again, which utopia-php/migration needs.This only works if each field has a default the spec can emit. The spec drops a default its schema rejects, such as
''on an enum rule or a scalar on an array rule.Changes
AGENTS.md, under Models: a required rule needs a default its schema accepts (an enum member, or an array for an array rule). Otherwise make the rulerequired => false.New defaults for the four required fields that had none:
AuthProvider.enabledfalseEmbedding.model''Embedding.dimension0JWT.jwt''Many required fields still have a default the spec can't emit. They're old fields that every server has always sent, mostly
statusenums and$permissionsarrays defaulting to'', so they're left as they are.Closes #14367