Fix: Index out of bounds panic in SwaggerUIHandler for files without extension#3217
Merged
Umang01-hash merged 6 commits intoApr 29, 2026
Conversation
…without extension Validate file extension using filepath.Ext before accessing it. Previously, splitting on "." and accessing index [1] would panic for filenames without a dot. Fixes gofr-dev#3214
21f8cfb to
f8508c4
Compare
Umang01-hash
requested changes
Apr 7, 2026
…IHandler Replace plain errors.New() with gofrHTTP.ErrorEntityNotFound so the framework correctly maps it to 404 Not Found instead of 500 Internal Server Error. A missing file extension is a client error, not a server error.
aryanmehrotra
approved these changes
Apr 29, 2026
Umang01-hash
approved these changes
Apr 29, 2026
Umang01-hash
approved these changes
Apr 29, 2026
Umang01-hash
added a commit
that referenced
this pull request
Apr 29, 2026
* chore(deps): consolidate minor dependency updates (2026-04-28) (#3365) Root module: - github.com/vektah/gqlparser/v2: 2.5.32 → 2.5.33 - modernc.org/sqlite: 1.49.1 → 1.50.0 - github.com/segmentio/kafka-go: 0.4.50 → 0.4.51 Submodules: - pkg/gofr/datasource/elasticsearch: go-elasticsearch/v8 8.19.4 → 8.19.5 - pkg/gofr/datasource/couchbase: gocb/v2 2.12.1 → 2.12.2 - gofr.dev 1.56.1 → 1.56.3 in 11 sub-modules (pubsub/sqs, pubsub/nats, pubsub/eventhub, file/sftp, file/s3, file/gcs, file/ftp, file/azure, oracle, dbresolver, examples/using-add-filestore) GitHub Actions: - crate-ci/typos: 1.45.1 → 1.45.2 Closes: #3364, #3363, #3362, #3361, #3360, #3359, #3358, #3357, #3356, #3355, #3354, #3353, #3352, #3351, #3350, #3349, #3348 Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Fix: Index out of bounds panic in SwaggerUIHandler for files without extension (#3217) * fix(kafka): reconnect stale admin conn instead of failing forever (#3347) * update release version to v1.56.4 --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Nitin Kumar Patel <nitin.kumar@zop.dev> Co-authored-by: Aryan Mehrotra <aryan.mehrotra@gofr.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
strings.Split+ direct index access withfilepath.Extto safely extract the file extension.errMissingFileExtension) when the filename has no extension, instead of panicking with index out of bounds.Fixes #3214
Test plan
TestSwaggerUIHandler_NoFileExtensionunit test