Skip to content

fix(specs): omit invalid timezone and annotated enum defaults - #13545

Merged
ChiragAgg5k merged 1 commit into
mainfrom
fix/openapi-enum-defaults
Sep 8, 2026
Merged

ChiragAgg5k merged 1 commit into
mainfrom
fix/openapi-enum-defaults

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

Summary

Fix invalid defaults on titled OpenAPI enum schemas, including screenshot timezone with default: "" despite its timezone enum excluding the empty string.

Found by strict validation of genuine Cloud workflow artifacts in Cloud #5716, after the object-default fix in #13544. This is a separate follow-up for CLO-4377, based directly on main rather than the optional-security branch.

The producer's existing default-eligibility check recognized plain enum and items.enum, but named enums now use titled oneOf branches. Extend the enum-default check to evaluate oneOf/anyOf branches and array items recursively:

  • Omit defaults that are not permitted by the emitted enum, rather than changing the enum or inventing a timezone default.
  • Retain valid scalar defaults, valid array defaults, and empty arrays.
  • Preserve open enums: the free-string alternative still permits values outside the named enum.

No route validator, runtime behavior, or API authentication changes. This is an enum-default eligibility check, not a general JSON Schema validator.

Spec change

GET /avatars/screenshots → optional timezone query parameter. Relevant schema excerpt below; the enum branches are abbreviated. This illustrates the intended change, not a newly generated full Cloud artifact.

 schema:
   type: string
   title: Timezone
   oneOf:
     - type: string
       enum: [africa/abidjan]
       title: africa/abidjan
     # ... remaining timezone branches unchanged ...
     - type: string
       enum: [utc]
       title: utc
-  default: ""

The invalid default is omitted—not replaced with utc or added to the enum. The parameter remains optional, and omission continues to use the browser's default timezone. Valid enum defaults remain unchanged.

Verification

  • Added GET-query and POST-request-body regressions using real route and enum metadata. Both failed before the production change because the invalid default was emitted, then passed after the fix.
  • Coverage includes the empty timezone sentinel, valid timezone defaults, invalid/valid/empty enum-array defaults, and open scalar/array enums.
  • vendor/bin/phpunit tests/unit/SDK/Specification/FormatTest.php — passed: 40 tests, 232 assertions.
  • vendor/bin/pint --test src/Appwrite/SDK/Specification/Format.php tests/unit/SDK/Specification/FormatTest.php — passed.
  • composer refactor:check — passed.
  • git diff --check — passed.

Not run for this branch: full Cloud spec generation, strict validation of the full resulting document, SDK output comparison, runtime e2e, or full-project static analysis. Further spec validation failures may surface after this one is removed; this PR does not claim the full canonical document is validator-clean. No screenshots apply to this nonvisual formatter change.

@greptile-apps

greptile-apps Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

The production change appears safe, but the implementation-coupled schema assertions violate an explicit repository testing requirement and should be removed before merging.

Fix All in Claude CodeFindings

  1. P2 Tests Mirror Schema Internals ▶

Summary

  • Invalid enum defaults are omitted while valid scalar, array, empty-array, and open-enum defaults remain.
  • Regression coverage exercises both query parameters and request-body properties.
  • The production change appears behaviorally sound for the schema shapes supplied by its current caller, but several new test assertions are unnecessarily coupled to the formatter’s internal schema representation.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/openapi-enum-defaults (after).

Metric Before After Change
🚀 Requests/sec 165.4 165.54 ⚪ +0.1%
⏱️ Latency P50 105.94 ms 104.66 ms ⚪ -1.2%
⏱️ Latency P95 247.56 ms 246.16 ms ⚪ -0.6%
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 104.66 246.16 10,260 165.54 -1.4
Account 217.66 389.69 540 9.45 +4.39
TablesDB 100.21 182.92 5,580 92.91 -1.08
Storage 99.95 212.85 2,700 46.32 -0.87
Functions 154.95 289.84 1,440 25.54 -20.98

Top API waits (after)

API request Max wait (ms)
account.name.update 604.53
account.prefs.update 603.24
functions.create 554.42
functions.variables.update 496.87
functions.variables.delete 487.32

@ChiragAgg5k
ChiragAgg5k merged commit 0c0dd72 into main Sep 8, 2026
46 of 48 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix/openapi-enum-defaults branch September 8, 2026 18:03
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.

2 participants