Repository navigation
fix: make interval optional on Function and Schedule models - #14311
Conversation
|
Review complete. 🟡 2 medium 💬 Inline comments (2)
The change adds
Reviewed commit: dc37ea7 |
🟢 Tier S · Ready to mergeThe existing default values and examples remain defined for both fields.
📂 Walkthrough · 2
🔇 Filtered out · 1Findings Hansi considered but did not post.
Reviewed |
Security rulesNo new WARNING or ERROR findings from security rules. 32 existing findings tracked in
|
There was a problem hiding this comment.
This PR marks the interval rule as non-required in the Func and Schedule response models, but that flag also changes runtime serialization and the generated OpenAPI contract.
Key findings
- 🟡 Keep
intervalrequiredinFuncmodel — Func.php:135 - 🟡 Keep
intervalrequiredinSchedulemodel — Schedule.php:66
| 'type' => self::TYPE_INTEGER, | ||
| 'description' => 'Minutes between scheduled executions. 0 when the function has no interval.', | ||
| 'default' => 0, | ||
| 'required' => false, |
There was a problem hiding this comment.
🟡 bug · medium
Keep interval required in Func model
Setting 'required' => false on the interval rule (src/Appwrite/Utopia/Response/Model/Func.php:135) changes runtime serialization, not just documentation: Response::output() applies the rule's 'default' => 0 only for required rules and emits null for non-required ones (src/Appwrite/Utopia/Response.php:556-558). A function document lacking interval (e.g. when the V25 attribute backfill fails and only warns, src/Appwrite/Migration/Version/V25.php:229-236) now serializes interval: null, contradicting the documented "0 when no interval" contract. It also drops interval from the generated OpenAPI required array, silently changing SDK types.
📋 Prompt for AI Agents
In src/Appwrite/Utopia/Response/Model/Func.php around line 135, delete the 'required' => false, line from the interval addRule options. Rationale: Response::output() (src/Appwrite/Utopia/Response.php:547-559) only applies the rule's default (0) when the rule is required; with required=false a missing document attribute serializes as null, breaking the documented '0 when no interval' contract, and the generated OpenAPI required array loses interval. Writers always persist interval, so requiredness is accurate.
| 'type' => self::TYPE_INTEGER, | ||
| 'description' => 'Minutes between runs. 0 when the schedule has no interval.', | ||
| 'default' => 0, | ||
| 'required' => false, |
There was a problem hiding this comment.
🟡 bug · medium
Keep interval required in Schedule model
The same 'required' => false flag on the Schedule model's interval rule (src/Appwrite/Utopia/Response/Model/Schedule.php:66) makes Response::output() emit interval: null for schedule documents missing the attribute instead of the documented default 0 — plausible here because the V25 migration creates the interval attribute on the console schedules collection with failures swallowed as warnings (src/Appwrite/Migration/Version/V25.php:93-99). The generated OpenAPI schema also stops listing interval as required, silently changing the published spec and SDK types. The same issue appears in src/Appwrite/Utopia/Response/Model/Func.php at line 135.
📋 Prompt for AI Agents
In src/Appwrite/Utopia/Response/Model/Schedule.php around line 66, delete the 'required' => false, line from the interval addRule options. With required=false, Response::output() serializes a missing interval as null instead of the rule default 0, contradicting the '0 when the schedule has no interval' description and removing interval from the OpenAPI required array. Schedule writers always persist interval, so the flag should be dropped.
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Follow-up to #14231 and #14307, needed before the SDK releases that add
interval.intervalwas a required property on theFunctionandScheduleresponse models. The new SDKs are generated against the 2.4.x spec, but self-hosted 2.4 servers don't returninterval. Typed SDKs (Dart, Kotlin, Swift, .NET, Python, Rust) would then fail to parse everyFunctionreturned by a 2.4 server.Marking it
required: falsemakes the property optional in the generated models, so the new SDKs keep working against servers that predate intervals. Servers with this feature still return the value: thefunctionsandschedulescollections defaultintervalto 0, so the response always carries a number.Test Plan
FunctionsScheduleTestandSchedulesConsoleClientTestassertions oninterval(0 and set values) still hold. The change only affects the generated spec, which e2e can't observe.Related: #14170