Skip to content

fix(api): missing trailing / route for environment-document - #15

Merged
gagantrivedi merged 2 commits into
Flagsmith:mainfrom
CentreonLabs:fix-edge-proxy-flagsmith
Sep 1, 2026
Merged

fix(api): missing trailing / route for environment-document#15
gagantrivedi merged 2 commits into
Flagsmith:mainfrom
CentreonLabs:fix-edge-proxy-flagsmith

Conversation

@Totodore

Copy link
Copy Markdown
Contributor

Each route was duplicated manually to work with trailing slash. However the /environment-document path was not. And the Rust SDK use /environment-document/ leading to 404.

Fix this by using the NormalizePathLayer rather than duplicating the routes which is error prone.

Side notes

Error message in the rust SDK are particularly not helpful: Failed to update environment: Flagsmith API error: . Will retry on next interval.. I will open a PR later to fix this.

Don't hesitate if this need any change.

@emyller emyller 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.

LGTM — thanks for the contribution!

@emyller emyller 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.

Sorry for taking my previous approval back. Would you think it makes sense to ensure the intended behaviour in tests?

@Totodore

Copy link
Copy Markdown
Contributor Author

I don't really see the point because the behavior is automatically standardized for every endpoints with the NormalizeLayer. The test would only cover an accidental removal of the layer which is likely unprobable.
If you insist I can definitely add tests, as you want.

@Totodore
Totodore requested a review from emyller August 18, 2026 08:02

@gagantrivedi gagantrivedi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

err.. looks like this is breaking our tests — middleware added with Router::layer runs after routing, so the normalize layer never sees the trailing slash. We probably need to wrap the layer around the whole router instead? https://docs.rs/axum/latest/axum/middleware/index.html#rewriting-request-uri-in-middleware

@gagantrivedi
gagantrivedi requested review from gagantrivedi and removed request for emyller August 24, 2026 08:20
@gagantrivedi
gagantrivedi dismissed emyller’s stale review September 1, 2026 04:47

covered by existing tests

@gagantrivedi
gagantrivedi merged commit e9442f4 into Flagsmith:main Sep 1, 2026
3 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.

3 participants