Skip to content

Answer cascade false from the cascade reader for a version that does not cascade - #3026

Merged
ericproulx merged 1 commit into
masterfrom
fix/cascade-reader
Oct 11, 2026
Merged

ericproulx merged 1 commit into
masterfrom
fix/cascade-reader

Conversation

@ericproulx

Copy link
Copy Markdown
Contributor

The cascade reader and the compiled API each worked out whether an API cascades, and they disagreed:

class A < Grape::API
  version 'v1', using: :header, vendor: 'x', cascade: false
end

A.cascade              # => true
A.compile!.cascade?    # => false, and responses lose X-Cascade

API::Instance#resolve_cascade used the cascade DSL's value, then the cascade: option of version, then true. DSL::Routing#cascade skipped version and went straight to true.

Change

  • The reader holds the one resolution: the value given to cascade, else version's cascade:, else true.
  • The compiled API reads it there (self.class.cascade), and resolve_cascade is gone. It is still read once, in the constructor.

Tests

  • .cascade specs: a version declared with cascade: false reads back false, and a later cascade true still wins over it. The first fails on master.
  • The two "does not cascade" request specs checked last_response.headers.keys for 'X-Cascade'. Rack 3 lowercases header names, so they passed whatever the response carried. They now read headers['X-Cascade'], like the "cascades" specs next to them.

Mutation-checked: dropping the version fallback fails the new reader spec and the version request spec. A compiled API that ignores the reader fails both request specs. Before the spec fix, neither mutation failed a request spec.

🤖 Generated with Claude Code

@ericproulx
ericproulx requested a review from dblock October 10, 2026 22:37
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Danger Report

No issues found.

View run

…not cascade

The cascade reader and the compiled API each resolved the setting. The
compiled API fell back to the cascade: option of version, the reader went
straight to true, so with `version 'v1', cascade: false` API.cascade
answered true for an API that did not cascade.

The reader now holds the one resolution, and the compiled API reads it
there. The two specs meant to pin that a request does not cascade looked
for 'X-Cascade' among the header keys, which Rack 3 lowercases, so they
passed whatever the response carried; they now read the header.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ericproulx
ericproulx merged commit 19e15d2 into master Oct 11, 2026
69 checks passed
@ericproulx
ericproulx deleted the fix/cascade-reader branch October 11, 2026 08:31
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