Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic caused by URL based versioning #1797

Merged
merged 1 commit into from
Jun 27, 2018
Merged

Conversation

buger
Copy link
Member

@buger buger commented Jun 27, 2018

getVersionFromRequest do not get in account NotVersioned flag, and UI by default writes a.VersionDefinition.Location field, so this check for version inside url was running for all non-versioned APIs.

In case of cloud, it was causing panics, because nginx layer maps slug to listenpath and actual user URL does not contain listen path, and can be even smaller (which cause panic). Replaced manual array operation with strings.TrimPrefix which checks array bounds, and added support for stripping slug from URL too (for cloud case).

`getVersionFromRequest` do not get in account `NotVersioned` flag, and
UI by default writes `a.VersionDefinition.Location` field, so this
check for version inside url was running for all non versioned APIs.

In case of cloud it was causing panics, because nginx layer maps `slug`
to `listenpath` and actual user URL does not contain listen path, and
can be even smaller (which cause panic). Replaced manual array
operation with `strings.TrimPrefix` which checks array bounds, and
added support for stripping slug from URL too (for cloud case).
@buger buger added the bug label Jun 27, 2018
@buger buger merged commit d0da57c into master Jun 27, 2018
@buger buger deleted the fix-url-versioning-bug branch June 27, 2018 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant