Skip to content

fix: prevent zstd Accept-Encoding panic in API middleware#1589

Open
saschabuehrle wants to merge 1 commit into
TwiN:masterfrom
saschabuehrle:fix/issue-1546-fasthttp-zstd
Open

fix: prevent zstd Accept-Encoding panic in API middleware#1589
saschabuehrle wants to merge 1 commit into
TwiN:masterfrom
saschabuehrle:fix/issue-1546-fasthttp-zstd

Conversation

@saschabuehrle
Copy link
Copy Markdown

Bug

Fixes #1546 — requests with Accept-Encoding: zstd could panic the server with unknown encoder level when using default compression middleware settings.

Fix

  • Configure Fiber compression middleware with an explicit LevelBestSpeed
  • Add a regression API test that requests /js/app.js with Accept-Encoding: zstd and asserts a successful response

This avoids passing an invalid zstd encoder level through the stack while keeping compression enabled.

Testing

  • go test ./api

Happy to address any feedback.

Greetings, saschabuehrle

@github-actions github-actions Bot added the bug Something isn't working label Mar 19, 2026
Comment thread api/api.go
// Middlewares
app.Use(recover.New())
app.Use(compress.New())
app.Use(compress.New(compress.Config{Level: compress.LevelBestSpeed}))
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Why is this change necessary?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic: unknown encoder level when opening web UI

2 participants