Skip to content

[rust-axum] fix: support range response status codes (4XX, 5XX) - #25555

Merged
wing328 merged 5 commits into
masterfrom
teovillanueva-fix/rust-axum-range-responses
Nov 4, 2026
Merged

wing328 merged 5 commits into
masterfrom
teovillanueva-fix/rust-axum-range-responses

Conversation

@wing328

@wing328 wing328 commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

based on #25294 with resolved merge conflicts

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Summary by cubic

Fixes the rust-axum generator so range status codes like 4XX and 5XX are sent as the concrete status chosen by the implementation instead of being dropped or replaced at the call site.

Previously the selectable status ended up emitting a fixed code and relied on body.code.parse(). Now each range response variant carries a status: u16 field, and the generated server applies it with StatusCode::from_u16, returning a 500 when the value is invalid. The change covers empty, JSON, and SSE responses, and applies all headers attached to the range response.

Written for commit 26c2a8e. Summary will update on new commits.

View guided diff Turn on auto-fix

@wing328 wing328 changed the title Teovillanueva fix/rust axum range responses [rust-axum] fix: support range response status codes (4XX, 5XX) Nov 4, 2026
@wing328
wing328 marked this pull request as ready for review November 4, 2026 08:50

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

2 issues found across 18 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="samples/server/petstore/rust-axum/output/rust-axum-range-responses/README.md">

<violation number="1" location="samples/server/petstore/rust-axum/output/rust-axum-range-responses/README.md:33">
P2: The README documents a nonexistent `conversions` feature. Rename it to `conversion` so users can enable the feature declared by this crate.</violation>

<violation number="2" location="samples/server/petstore/rust-axum/output/rust-axum-range-responses/README.md:47">
P2: The example implements the nonexistent `apis::default::Api` trait. Use `apis::default::Default` to match the trait this generated crate exposes.</violation>
</file>

Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.

View guided diff | Turn on auto-fix | Re-trigger cubic

* This defaults to enabled and creates the basic skeleton of a server implementation based on Axum.
* To create the server stack you'll need to provide an implementation of the API trait to provide the server function.
* Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies (including `ammonia`, so the XSS check in model validation is skipped), e.g. for sharing the models with a WASM frontend.
* `conversions`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: The README documents a nonexistent conversions feature. Rename it to conversion so users can enable the feature declared by this crate.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/server/petstore/rust-axum/output/rust-axum-range-responses/README.md, line 33:

<comment>The README documents a nonexistent `conversions` feature. Rename it to `conversion` so users can enable the feature declared by this crate.</comment>

<file context>
@@ -0,0 +1,94 @@
+    * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum.
+    * To create the server stack you'll need to provide an implementation of the API trait to provide the server function.
+    * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies (including `ammonia`, so the XSS check in model validation is skipped), e.g. for sharing the models with a WASM frontend.
+* `conversions`
+    * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types.
+
</file context>
Suggested change
* `conversions`
* `conversion`


#[allow(unused_variables)]
#[async_trait]
impl rust_axum_range_responses_test::apis::default::Api for ServerImpl {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: The example implements the nonexistent apis::default::Api trait. Use apis::default::Default to match the trait this generated crate exposes.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/server/petstore/rust-axum/output/rust-axum-range-responses/README.md, line 47:

<comment>The example implements the nonexistent `apis::default::Api` trait. Use `apis::default::Default` to match the trait this generated crate exposes.</comment>

<file context>
@@ -0,0 +1,94 @@
+
+#[allow(unused_variables)]
+#[async_trait]
+impl rust_axum_range_responses_test::apis::default::Api for ServerImpl {
+  // API implementation goes here
+}
</file context>

@wing328
wing328 merged commit 95fbeeb into master Nov 4, 2026
25 of 301 checks passed
@wing328
wing328 deleted the teovillanueva-fix/rust-axum-range-responses branch November 4, 2026 09:52
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