Skip to content

fix: make interval optional on Function and Schedule models - #14311

Merged
ChiragAgg5k merged 1 commit into
mainfrom
fix/function-interval-optional-model
Oct 9, 2026
Merged

ChiragAgg5k merged 1 commit into
mainfrom
fix/function-interval-optional-model

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #14231 and #14307, needed before the SDK releases that add interval.

interval was a required property on the Function and Schedule response models. The new SDKs are generated against the 2.4.x spec, but self-hosted 2.4 servers don't return interval. Typed SDKs (Dart, Kotlin, Swift, .NET, Python, Rust) would then fail to parse every Function returned by a 2.4 server.

Marking it required: false makes 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: the functions and schedules collections default interval to 0, so the response always carries a number.

Test Plan

  • Existing FunctionsScheduleTest and SchedulesConsoleClientTest assertions on interval (0 and set values) still hold. The change only affects the generated spec, which e2e can't observe.
  • Pint passes.

Related: #14170

@luxor-code-review

luxor-code-review Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Review complete. 🟡 2 medium

💬 Inline comments (2)


The change adds 'required' => false to the interval rule in two API response models, intending to relax the declared contract. Because the same flag drives Response::output(), it also changes how missing attributes serialize and how the OpenAPI schema declares requiredness.

Files Change
src/Appwrite/Utopia/Response/Model/Func.php Adds 'required' => false to the interval rule, which can serialize null instead of the documented default 0 and drops interval from the generated spec's required list.
src/Appwrite/Utopia/Response/Model/Schedule.php Same 'required' => false flag on its interval rule, with the identical serialization and spec-contract impact.

Reviewed commit: dc37ea7

@ChiragAgg5k ChiragAgg5k self-assigned this Oct 9, 2026
@ghost

ghost commented Oct 9, 2026

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The existing default values and examples remain defined for both fields.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 2
File Change
src/Appwrite/Utopia/Response/Model/Func.php Marks the Function interval response property optional.
src/Appwrite/Utopia/Response/Model/Schedule.php Marks the Schedule interval response property optional.
🔇 Filtered out · 1

Findings Hansi considered but did not post.

Finding Why
Keep the runtime default when interval is absent Verifier: The null fallback is real, but the claimed non-null SDK contract violation is not. OpenAPI3.php:1181 derives required properties from Model::getRequired(), and lines 1363–1364 explicitly set nullable=true for every non-required property. Thus this change makes interval both optional and nullable in the generated SDK schema, matching Response::output()'s null serialization. V25 leaving legacy intervals unset does not establish a schema mismatch or a need to preserve 0 independently.

Reviewed dc37ea7 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

@ChiragAgg5k
ChiragAgg5k merged commit c814e4d into main Oct 9, 2026
21 checks passed
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

32 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (17)
  • php.appwrite.permissive-write-permission (8)
  • php.appwrite.secret-compare-timing (5)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@luxor-code-review luxor-code-review Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

'type' => self::TYPE_INTEGER,
'description' => 'Minutes between scheduled executions. 0 when the function has no interval.',
'default' => 0,
'required' => false,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/function-interval-optional-model (after).

Metric Before After Change
🚀 Requests/sec 194.38 202.43 ⚪ +4.1%
⏱️ Latency P50 88.82 ms 86.46 ms ⚪ -2.7%
⏱️ Latency P95 208.94 ms 193.24 ms 🟢 -7.5%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 86.46 193.24 12,654 202.43 -15.7
Account 165.05 312.25 666 11.06 +6.2
TablesDB 84.59 157.27 6,882 111.36 -17.81
Storage 77.53 163 3,330 56.08 -8.85
Functions 120.85 221.6 1,776 30.75 -11.34

Top API waits (after)

API request Max wait (ms)
account.name.update 476.89
account.prefs.update 398.63
functions.variables.update 396.63
tablesdb.rows.create 379.94
functions.create 355.81

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant