Skip to content

fix: infer response media and Rust bodyless results from OpenAPI - #1888

Merged
ChiragAgg5k merged 2 commits into
mainfrom
clo-4377-produces
Sep 8, 2026
Merged

fix: infer response media and Rust bodyless results from OpenAPI#1888
ChiragAgg5k merged 2 commits into
mainfrom
clo-4377-produces

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Sep 8, 2026

Copy link
Copy Markdown
Member

Derive Accept and Rust response types from standard response content

PR 4/4. CLO-4377: https://linear.app/appwrite/issue/CLO-4377/openapi3-standards
Appwrite #13524 and canonical specs latest #110 / 2.0.x #111 are merged. Both published documents match the reviewed SHA256 7bf999d8faec746c1fb0ead1f0539dfaa8aead401405b2b697358e7059667f98 and contain no x-appwrite.produces. The branch is in sync with SDK-generator main; no parser release is required. Cloud's older server-ce pin remains unchanged; the owner explicitly approved publishing specs without waiting for that promotion.

Generated SDK changes

Actual generated Rust console account.delete_billing_address:

 pub async fn delete_billing_address(
     &self,
     billing_address_id: impl Into<String>,
-) -> crate::error::Result<serde_json::Value> {
+) -> crate::error::Result<()> {

Actual generated Rust account.delete now sends:

api_headers.insert("content-type".to_string(), "application/json".to_string());
api_headers.insert("accept".to_string(), "application/json".to_string());

Actual generated Node server adds this metadata for bodyless operations:

accept: 'application/json',

Spec evidence: genuine CE sitesDeleteLog after-generation still declares only:

"responses": {"204": {"description": "No content"}}

There is no response body, and no fallback extension. Explicit response content continues to determine Accept; binary/location and OAuth return branches are unchanged. Existing Swagger2 produces remains supported through the parser's standard response content conversion.

Breaking change / release notes

Rust methods previously inferred as Result<serde_json::Value> solely from the extension now return Result<()>. Callers binding those results must use () and must not expect JSON from a bodyless response. Keep this breaking API correction and the JSON Accept fallback in the eventual Rust SDK release notes; the changelog template is intentionally unchanged. Apply Rust SDK breaking-change version policy at publication.

Measured output

Fixed published canonical baseline (1,020 operations) has 117 bodyless operations: 49 with old extension and 68 without. Clean actual Rust generations show 11 client / 23 server / 38 console corrected signatures and 14 / 54 / 60 added Accept headers respectively. Counts depend on platform/exclusions/aliases. Other targets have only JSON Accept additions and necessary comma formatting; CLI/GraphQL output is unchanged. Rust has only approved signature/header changes, documentation signatures and strengthened integration harness.

Standard Swagger2 1.8.x server: explicit media and Rust signatures preserved; 39 JSON Accept insertions only where no produced content exists.

Validation

  • No new unit tests. Added an output-shape check in the existing generation suite and strengthened the existing Rust integration call to require successful unit deserialization.
  • New generation check observed red against baseline generator, green after. Full suite: 85 tests, 1,130 assertions, 4 existing skips.
  • Docker e2e: Rust 1 test / 131 assertions; Node + PHP 2 tests / 298 assertions; Go 1 test / 134 assertions. PHP separately 1 / 142.
  • PHP lint, Rector and Twig lint pass. Rust server cargo check and Rust client/server rustfmt pass.
  • Go build/vet/test, Web/Node/React Native formatting/lint/types, Node build+830 tests, Dart, Kotlin/Android, Swift/Apple, C#/Unity, Python Black, Ruby RuboCop and PHP Pint/PHPStan/Rector pass.
  • Existing published specs: 101 reference-valid documents; canonical and genuine CE before/after documents validator clean.

Existing gate limitations

  • Rust console rustfmt reports unchanged long constants in usage_event_metric.rs; reproduced on baseline.
  • Flutter formatter reports the same 20 files on baseline and after; no generated files were formatted in place.
  • Unchanged CLI cannot build without missing dependency/go.sum entries; reproduced on baseline. CLI output itself has zero differences.
  • Node's first test invocation lacked a build; rerun after npm run build passed all 830 tests.
  • Canonical artifacts are now publicly available following genuine x86 Cloud generation and specs feat-flutter-dart-sdk-private-storage-files #110/fix-flutter-dart-code-quality #111. Generation suite rerun passes: 85 tests / 1,130 assertions. Remote CI and Validation checks passed at 788f49ae7932608a5269d5049cad10f3b6bea429; fresh checks follow the changelog-only revert. An additional local Rust e2e rerun initially encountered mock-server connectivity failures; one unchanged-code environment retry passed (1 test, 131 assertions).

Follow-through

Cloud pins sdk-generator 4.9.*; CE allows ^4.0. After choosing and publishing the generator version, plan a targeted Cloud dependency promotion if that range excludes it. No speculative version bump here.

Captured validation output

Actual command-output excerpts rendered locally and captured with Chromium. These are test-log screenshots, not live browser UI/e2e screenshots. Local configuration paths are excluded by selecting the public stdout excerpt; result text is unchanged.

Captured command output

Narrow regression and full generation suite passed at 788f49ae7932608a5269d5049cad10f3b6bea429, based on SDK-generator main f072d890699106748a9899a344a6932b31a41118. Follow-up b251f6eeb removes only the proposed changelog-template entries; Rust server was regenerated successfully. No new unit tests.

@greptile-apps

greptile-apps Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR derives response media types from standard OpenAPI response content, defaults bodyless operations to JSON content negotiation, and updates Rust bodyless operations to return unit.

  • Removes the legacy x-appwrite.produces fallback.
  • Generates Accept: application/json when no response content type is declared.
  • Maps bodyless Rust responses to crate::error::Result<()>.
  • Strengthens generation and Rust integration coverage for the revised contract.
  • The previously reported case mismatch is not an issue: the assertion consumes generated files normalized by strtolower(), and the thread was resolved after Greptile withdrew the finding.

Confidence Score: 5/5

The PR appears safe to merge with no outstanding correctness or repository-rule findings.

No new code changes were made after the previous review, and the sole previous finding was manually resolved after Greptile conceded it: GenerationTest::generate() lowercases generated file contents before the assertion, so the lowercase Rust return-type pattern is correct.

Important Files Changed

Filename Overview
src/SDK/Extension/Appwrite.php Removes the obsolete Appwrite-specific response media extension constant.
src/SDK/Language/Rust.php Infers bodyless Rust unit results exclusively from standard response content.
src/SDK/SDK.php Defaults generated Accept metadata to application/json when responses declare no content.
templates/rust/tests/tests.rs Verifies successful unit deserialization for a generated bodyless Rust operation.
tests/generation/GenerationTest.php Checks normalized generated Rust output for unit return types and JSON Accept headers.
tests/resources/spec-openapi3.json Removes legacy produces metadata so tests exercise standard OpenAPI response inference.

Reviews (3): Last reviewed commit: "chore: leave Rust changelog template unc..." | Re-trigger Greptile

Comment thread tests/generation/GenerationTest.php
@ChiragAgg5k

Copy link
Copy Markdown
Member Author

@greptile review

@ChiragAgg5k

Copy link
Copy Markdown
Member Author

@greptile review

Please reassess the resolved case-mismatch finding with the actual assertion input: GenerationTest::generate() at tests/generation/GenerationTest.php:194 applies strtolower() to every file before returning $files. The new test uses that normalized result, NOT raw Rust source. It correctly expects lowercase crate::error::result; changing it to uppercase would break the test. Current-head focused command vendor/bin/phpunit --testsuite Generation --filter testRustBodylessResponsesUseUnitWithJsonAccept passes (1 test, 3 assertions). See thread reply #1888 (comment). No source edit is needed for this false positive.

@ChiragAgg5k
ChiragAgg5k merged commit 37c0c8c into main Sep 8, 2026
96 of 97 checks passed
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