Skip to content

🐛 bug: fix gocritic httpNoBody and hugeParam issues#3855

Merged
ReneWerner87 merged 8 commits intomainfrom
codex/2025-11-10-11-30-24
Nov 12, 2025
Merged

🐛 bug: fix gocritic httpNoBody and hugeParam issues#3855
ReneWerner87 merged 8 commits intomainfrom
codex/2025-11-10-11-30-24

Conversation

@ReneWerner87
Copy link
Member

Summary

  • replace nil HTTP request bodies in tests with http.NoBody so the gocritic httpNoBody check passes
  • refactor functions that previously accepted large structs by value to use pointer parameters across the app, middleware, and generated interfaces, updating all call sites and adding safety guards
  • adjust helper utilities (colors, logger defaults, prefork tests, proxy config, etc.) to align with the new pointer-based signatures while preserving existing behavior

Testing

  • make audit (fails: govulncheck cannot reach vuln.go.dev)
  • make generate
  • make betteralign
  • make modernize
  • make format
  • make test
  • go test ./...
  • GOTOOLCHAIN=go1.25.1 go run github.com/go-critic/go-critic/cmd/gocritic@latest check -enable httpNoBody ./...
  • GOTOOLCHAIN=go1.25.1 go run github.com/go-critic/go-critic/cmd/gocritic@latest check -enable hugeParam ./...

Codex Task

Copilot AI review requested due to automatic review settings November 10, 2025 11:30
@ReneWerner87 ReneWerner87 requested a review from a team as a code owner November 10, 2025 11:30
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 10, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

This PR converts many value parameters to pointer parameters, adds nil-safety and defensive copies where needed, standardizes empty-request tests to http.NoBody, replaces length checks with empty-string checks, introduces several named-return signatures, and adjusts numerous middleware and core call sites accordingly.

Changes

Cohort / File(s) Summary
Tests — request body standardization
adapter_test.go, app_test.go, bind_test.go, ctx_test.go, extractors/extractors_test.go, mount_test.go, listen_test.go, prefork_test.go, redirect_test.go, router_test.go, client/*.go, middleware/*/*_test.go, middleware/proxy/proxy_test.go
Replaced nil request bodies with http.NoBody, added net/http imports, and updated some test helpers to use named returns.
Route pointers & hooks
hooks.go, hooks_test.go, router.go, res.go, res_interface_gen.go, ctx_interface_gen.go, app.go, redirect.go
Changed route-related APIs to accept *Route, added nil-checks and clone-on-write in hooks, and updated call sites to pass pointers.
Listen / prefork pointer conversions
listen.go, prefork.go, listen_test.go, prefork_test.go
Converted ListenConfig parameters to *ListenConfig; callers now pass &cfg; callees add nil-safety initialization.
Middleware config / API changes
middleware/basicauth/basicauth.go, middleware/proxy/proxy.go, middleware/limiter/*.go, middleware/csrf/*.go, middleware/cors/cors.go, middleware/logger/*.go, middleware/session/middleware.go
Many middleware APIs changed: config params moved to pointers or variadic configs; internal helpers updated to pointer receivers with nil/default handling.
Color / ColorScheme pointer conversion
color.go, app.go, services.go, middleware/logger/tags.go, middleware/logger/utils.go
Color-related functions now accept *Colors/*ColorScheme, include nil checks and copy-to-default behavior; call sites updated to pass pointers.
String emptiness & small idioms
app.go, res.go, router.go, ctx.go, req.go, extractors/extractors.go, helpers.go, internal/storage/memory/memory.go, middleware/cors/utils.go, middleware/static/static.go, path.go
Replaced len(x) == 0 / len(x) > 0 checks with x == "" / x != "" and other minor idiomatic adjustments.
Request decoding & interface naming
req.go, req_interface_gen.go, ctx_interface_gen.go, res_interface_gen.go
Introduced named return values for body-decoding methods (tryDecodeBodyInOrder) and propagated signature changes to generated interfaces.
Binder & reflection safety
binder/mapping.go
isExported and fieldName now accept *reflect.StructField with nil checks; callers updated.
Internal memory & concurrency refactor
internal/memory/memory.go, internal/storage/memory/memory.go
Replaced embedded mutex with named mu sync.RWMutex, updated lock usage, added defensive copy for []byte stored values, and normalized empty-key checks.
Named returns / small refactors
helpers.go, internal/tlstest/tls.go, middleware/cache/heap.go, client/*.go, middleware/static/static.go
Converted several functions to named-return forms (with nolint), renamed locals (e.g., fsfileServer), and minor control-flow tweaks.
Other middleware & utilities
middleware/* (various), services.go, res.go, router.go
Pointer-safety adjustments, guard clauses, cache-control checks, and small API-usage updates across middleware and server helpers.

Sequence Diagram(s)

%%{init: {"themeVariables": {"actorBackground":"#f6f8fa","actorBorder":"#d0d7de","noteBackground":"#fff8dc","noteBorder":"#e6d9a8"}}}%%
sequenceDiagram
    participant App
    participant Router
    participant Hooks
    participant RouteHandler as Route

    Note over App,Router: Old flow (route value)
    App->>Router: addRoute(route)
    Router->>Hooks: executeOnRouteHooks(route)
    Hooks->>RouteHandler: handlers receive route (value)

    Note over App,Router: New flow (route pointer + clone)
    App->>Router: addRoute(route)
    Router->>Hooks: executeOnRouteHooks(&route)
    Hooks->>Hooks: if route==nil -> return error (guard)
    Hooks->>Hooks: cloned := *route
    Hooks->>Hooks: apply mountPath / modifications to cloned
    Hooks->>RouteHandler: pass cloned to handlers
    Note over RouteHandler: original route remains unchanged
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Areas needing extra attention:

  • Hooks/route pointer ownership and clone semantics (hooks.go, router.go, res.go, res_interface_gen.go)
  • Interface and signature changes for request/response decoding and named returns (req.go, req_interface_gen.go, ctx_interface_gen.go)
  • Concurrency and defensive-copy changes in internal memory storage (internal/memory/memory.go, internal/storage/memory/memory.go)
  • Variadic config handling and defaulting in middleware (e.g., middleware/proxy/proxy.go, middleware/basicauth/basicauth.go, middleware/limiter/*)
  • Broad pointer conversions — verify nil-safety across call sites and tests

Possibly related PRs

Suggested labels

☢️ Bug

Suggested reviewers

  • sixcolors
  • efectn

Poem

🐇
I hopped where pointers softly led,
Cloned each route and guarded thread,
NoBody filled the empty lanes,
Strings grew tidy, locks got names,
A rabbit cheers — tests pass ahead! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 41.61% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main purpose: fixing gocritic issues (httpNoBody and hugeParam) related to HTTP request body handling and large parameter passing.
Description check ✅ Passed The PR description provides a clear summary of changes, testing steps performed, and aligns with the repository's description template with appropriate details on the scope of modifications.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/2025-11-10-11-30-24

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ReneWerner87, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing code quality and performance by addressing specific gocritic linter issues. It standardizes the handling of empty HTTP request bodies in tests and implements a significant refactoring effort to optimize parameter passing for large data structures, ensuring more efficient memory usage across the application's core components and middleware.

Highlights

  • Gocritic httpNoBody Fix: Replaced all instances of nil HTTP request bodies with http.NoBody in test files across the codebase to comply with the gocritic httpNoBody linter rule. This ensures explicit handling of empty request bodies.
  • Gocritic hugeParam Refactoring: Refactored numerous functions and their call sites to pass large struct parameters by pointer instead of by value. This addresses the gocritic hugeParam linter warning, improving performance by avoiding unnecessary memory allocations and copies for large data structures.
  • Linter Configuration Update: The .golangci.yml configuration file has been updated to enable additional gocritic linter tags, specifically style and performance, ensuring broader code quality checks.
  • Helper Utilities Adjustment: Adjusted various helper utilities and core functions, including those related to color schemes, logger defaults, prefork tests, and proxy configurations, to align with the new pointer-based parameter signatures while maintaining existing behavior.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@ReneWerner87 ReneWerner87 added this to v3 Nov 10, 2025
@ReneWerner87 ReneWerner87 added this to the v3 milestone Nov 10, 2025
@codecov
Copy link

codecov bot commented Nov 10, 2025

Codecov Report

❌ Patch coverage is 76.58537% with 48 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.67%. Comparing base (19cc3f5) to head (b445ffe).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
listen.go 66.66% 4 Missing and 3 partials ⚠️
middleware/logger/default_logger.go 41.66% 5 Missing and 2 partials ⚠️
binder/mapping.go 55.55% 2 Missing and 2 partials ⚠️
hooks.go 71.42% 2 Missing and 2 partials ⚠️
middleware/logger/utils.go 33.33% 2 Missing and 2 partials ⚠️
middleware/limiter/limiter_fixed.go 25.00% 2 Missing and 1 partial ⚠️
middleware/limiter/limiter_sliding.go 25.00% 2 Missing and 1 partial ⚠️
color.go 91.30% 1 Missing and 1 partial ⚠️
middleware/cors/cors.go 75.00% 1 Missing and 1 partial ⚠️
middleware/csrf/config.go 50.00% 1 Missing and 1 partial ⚠️
... and 6 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3855      +/-   ##
==========================================
- Coverage   92.11%   91.67%   -0.44%     
==========================================
  Files         115      115              
  Lines        9776     9819      +43     
==========================================
- Hits         9005     9002       -3     
- Misses        490      517      +27     
- Partials      281      300      +19     
Flag Coverage Δ
unittests 91.67% <76.58%> (-0.44%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request refactors function signatures across the codebase to accept pointer parameters instead of value parameters for structs, improving performance by avoiding unnecessary copying. The changes also standardize test code by replacing nil with http.NoBody for HTTP request bodies, and enhance linter configuration.

Key changes:

  • Convert struct parameters to pointers in multiple functions (Colors, Route, Config types)
  • Add nil checks and default value handling where appropriate
  • Replace nil with http.NoBody in test request creation
  • Enable additional gocritic linter tags for style and performance

Reviewed Changes

Copilot reviewed 66 out of 66 changed files in this pull request and generated no comments.

Show a summary per file
File Description
services.go, services_test.go Changed logServices to accept *Colors pointer, updated test call
router.go Changed executeOnRouteHooks to accept *Route pointer
res.go, res_interface_gen.go, ctx_interface_gen.go Changed getLocationFromRoute to accept *Route pointer with nil check
redirect.go Updated to pass &route to getLocationFromRoute
prefork.go, prefork_test.go Changed prefork to accept *ListenConfig pointer with nil check
listen.go, listen_test.go Changed multiple functions to accept pointer parameters with nil checks
hooks.go, hooks_test.go Changed executeOnRouteHooks/executeOnNameHooks to accept *Route pointer with cloning
color.go, app.go Changed defaultColors to accept *Colors pointer with nil check
middleware/logger/*.go Changed color functions to accept *Colors pointer with nil checks
middleware/session/*.go Changed initialize to accept *Config pointer
middleware/limiter/*.go Changed Handler.New to accept *Config pointer with nil checks
middleware/cors/*.go Changed helper functions to accept *Config pointer with nil checks
middleware/csrf/*.go Changed multiple functions to accept *Config pointer
middleware/proxy/*.go Changed Balancer to accept variadic ...Config
middleware/basicauth/*.go Changed New to accept variadic ...Config
binder/mapping.go Changed isExported/fieldName to accept *reflect.StructField pointer
Multiple test files Replaced nil with http.NoBody in test request creation
.golangci.yml Added style and performance tags to gocritic configuration

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a significant refactoring to address gocritic linter warnings, specifically httpNoBody and hugeParam. The changes are extensive and touch many files, primarily replacing nil with http.NoBody in HTTP requests for tests and converting functions to accept pointers for large structs instead of values. These changes are well-executed and improve both code style and performance.
I've identified one potential issue where a nil check is insufficient, which could lead to a panic. I've left a comment with a suggestion to fix it. Overall, this is a great contribution to improving the codebase's quality.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
middleware/keyauth/keyauth_test.go (1)

136-144: Consider defaulting reqBody to http.NoBody for consistency.

For consistency with the other changes in this PR, initialize reqBody to http.NoBody instead of relying on the nil zero value:

-var reqBody io.Reader
+reqBody := http.NoBody
 if authSource == formExtractorName {
   form := url.Values{}
   form.Add(test.authTokenName, testKey)
   bodyStr := form.Encode()
   reqBody = strings.NewReader(bodyStr)
 }

This makes the intent more explicit and aligns with the systematic replacement of nil bodies throughout this file.

middleware/logger/default_logger.go (1)

17-24: Nil-check adds safety, but changes behavior.

The signature change to accept *Config aligns with the PR objective. The nil-check with default initialization is defensive programming, but note that it changes behavior: previously a nil cfg would panic (exposing caller bugs), now it silently uses defaults. Since defaultLoggerInstance is private, ensure all call sites pass a valid pointer—or document that nil is acceptable.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ee0ca7 and eb29c53.

⛔ Files ignored due to path filters (1)
  • .golangci.yml is excluded by !**/*.yml
📒 Files selected for processing (65)
  • adapter_test.go (3 hunks)
  • app.go (2 hunks)
  • app_test.go (47 hunks)
  • bind_test.go (3 hunks)
  • binder/mapping.go (2 hunks)
  • color.go (1 hunks)
  • ctx_interface_gen.go (1 hunks)
  • ctx_test.go (49 hunks)
  • extractors/extractors_test.go (1 hunks)
  • hooks.go (1 hunks)
  • hooks_test.go (3 hunks)
  • listen.go (9 hunks)
  • listen_test.go (4 hunks)
  • middleware/adaptor/adaptor_test.go (9 hunks)
  • middleware/basicauth/basicauth.go (1 hunks)
  • middleware/basicauth/basicauth_test.go (20 hunks)
  • middleware/cache/cache_test.go (56 hunks)
  • middleware/compress/compress_test.go (30 hunks)
  • middleware/cors/cors.go (4 hunks)
  • middleware/cors/cors_test.go (2 hunks)
  • middleware/csrf/config.go (1 hunks)
  • middleware/csrf/csrf.go (8 hunks)
  • middleware/csrf/csrf_test.go (11 hunks)
  • middleware/earlydata/earlydata_test.go (6 hunks)
  • middleware/encryptcookie/encryptcookie_test.go (4 hunks)
  • middleware/envvar/envvar_test.go (7 hunks)
  • middleware/etag/etag_test.go (9 hunks)
  • middleware/expvar/expvar_test.go (6 hunks)
  • middleware/favicon/favicon_test.go (7 hunks)
  • middleware/healthcheck/healthcheck_test.go (3 hunks)
  • middleware/helmet/helmet_test.go (8 hunks)
  • middleware/idempotency/idempotency_test.go (11 hunks)
  • middleware/keyauth/keyauth_test.go (30 hunks)
  • middleware/limiter/limiter.go (2 hunks)
  • middleware/limiter/limiter_fixed.go (1 hunks)
  • middleware/limiter/limiter_sliding.go (1 hunks)
  • middleware/limiter/limiter_test.go (32 hunks)
  • middleware/logger/config.go (1 hunks)
  • middleware/logger/default_logger.go (3 hunks)
  • middleware/logger/logger.go (2 hunks)
  • middleware/logger/logger_test.go (31 hunks)
  • middleware/logger/tags.go (1 hunks)
  • middleware/logger/utils.go (2 hunks)
  • middleware/pprof/pprof_test.go (11 hunks)
  • middleware/proxy/proxy.go (2 hunks)
  • middleware/proxy/proxy_test.go (34 hunks)
  • middleware/recover/recover_test.go (4 hunks)
  • middleware/redirect/redirect_test.go (9 hunks)
  • middleware/requestid/requestid_test.go (4 hunks)
  • middleware/rewrite/rewrite_test.go (5 hunks)
  • middleware/session/middleware.go (3 hunks)
  • middleware/skip/skip_test.go (4 hunks)
  • middleware/static/static_test.go (48 hunks)
  • middleware/timeout/timeout_test.go (8 hunks)
  • mount_test.go (17 hunks)
  • prefork.go (1 hunks)
  • prefork_test.go (4 hunks)
  • redirect.go (1 hunks)
  • redirect_test.go (4 hunks)
  • res.go (2 hunks)
  • res_interface_gen.go (1 hunks)
  • router.go (2 hunks)
  • router_test.go (41 hunks)
  • services.go (1 hunks)
  • services_test.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

**/*.go: Apply formatting using gofumpt (Make target: format)
Optimize struct field alignment using betteralign (Make target: betteralign)
Modernize code using gopls modernize (Make target: modernize)

Files:

  • middleware/pprof/pprof_test.go
  • middleware/favicon/favicon_test.go
  • middleware/cache/cache_test.go
  • middleware/logger/logger_test.go
  • middleware/recover/recover_test.go
  • middleware/limiter/limiter_test.go
  • middleware/proxy/proxy_test.go
  • middleware/logger/tags.go
  • res_interface_gen.go
  • middleware/basicauth/basicauth.go
  • middleware/proxy/proxy.go
  • middleware/csrf/config.go
  • middleware/healthcheck/healthcheck_test.go
  • middleware/envvar/envvar_test.go
  • redirect_test.go
  • middleware/logger/utils.go
  • middleware/earlydata/earlydata_test.go
  • ctx_test.go
  • res.go
  • prefork.go
  • adapter_test.go
  • middleware/encryptcookie/encryptcookie_test.go
  • middleware/adaptor/adaptor_test.go
  • prefork_test.go
  • middleware/requestid/requestid_test.go
  • hooks.go
  • middleware/expvar/expvar_test.go
  • middleware/limiter/limiter.go
  • middleware/logger/config.go
  • router_test.go
  • hooks_test.go
  • middleware/timeout/timeout_test.go
  • middleware/cors/cors_test.go
  • app_test.go
  • app.go
  • bind_test.go
  • middleware/compress/compress_test.go
  • listen_test.go
  • ctx_interface_gen.go
  • middleware/keyauth/keyauth_test.go
  • middleware/basicauth/basicauth_test.go
  • middleware/helmet/helmet_test.go
  • middleware/rewrite/rewrite_test.go
  • mount_test.go
  • services.go
  • middleware/redirect/redirect_test.go
  • middleware/session/middleware.go
  • color.go
  • redirect.go
  • listen.go
  • middleware/idempotency/idempotency_test.go
  • services_test.go
  • middleware/csrf/csrf.go
  • middleware/limiter/limiter_sliding.go
  • middleware/etag/etag_test.go
  • extractors/extractors_test.go
  • middleware/limiter/limiter_fixed.go
  • middleware/cors/cors.go
  • binder/mapping.go
  • middleware/static/static_test.go
  • router.go
  • middleware/logger/logger.go
  • middleware/logger/default_logger.go
  • middleware/skip/skip_test.go
  • middleware/csrf/csrf_test.go
🧠 Learnings (22)
📚 Learning: 2025-10-16T07:19:52.418Z
Learnt from: grivera64
Repo: gofiber/fiber PR: 3807
File: adapter_test.go:118-144
Timestamp: 2025-10-16T07:19:52.418Z
Learning: In the Fiber codebase, the linter does not allow `require` assertions from within HTTP handlers (including net/http-style handlers). Use `t.Fatalf`, `t.Errorf`, or similar `testing.T` methods for error handling inside handler functions instead.

Applied to files:

  • middleware/pprof/pprof_test.go
  • middleware/favicon/favicon_test.go
  • middleware/cache/cache_test.go
  • middleware/logger/logger_test.go
  • middleware/recover/recover_test.go
  • middleware/limiter/limiter_test.go
  • middleware/proxy/proxy_test.go
  • middleware/healthcheck/healthcheck_test.go
  • middleware/envvar/envvar_test.go
  • redirect_test.go
  • middleware/earlydata/earlydata_test.go
  • ctx_test.go
  • adapter_test.go
  • middleware/encryptcookie/encryptcookie_test.go
  • middleware/adaptor/adaptor_test.go
  • middleware/requestid/requestid_test.go
  • middleware/expvar/expvar_test.go
  • router_test.go
  • middleware/timeout/timeout_test.go
  • middleware/cors/cors_test.go
  • app_test.go
  • bind_test.go
  • middleware/compress/compress_test.go
  • middleware/keyauth/keyauth_test.go
  • middleware/basicauth/basicauth_test.go
  • middleware/helmet/helmet_test.go
  • middleware/rewrite/rewrite_test.go
  • mount_test.go
  • middleware/redirect/redirect_test.go
  • middleware/idempotency/idempotency_test.go
  • middleware/etag/etag_test.go
  • middleware/static/static_test.go
  • middleware/skip/skip_test.go
  • middleware/csrf/csrf_test.go
📚 Learning: 2024-10-08T19:06:06.583Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 2922
File: middleware/cors/utils.go:63-71
Timestamp: 2024-10-08T19:06:06.583Z
Learning: The project uses the testify/assert package for assertions in unit tests.

Applied to files:

  • middleware/pprof/pprof_test.go
  • middleware/cache/cache_test.go
  • middleware/logger/logger_test.go
  • middleware/recover/recover_test.go
  • middleware/limiter/limiter_test.go
  • middleware/healthcheck/healthcheck_test.go
  • middleware/earlydata/earlydata_test.go
  • ctx_test.go
  • middleware/encryptcookie/encryptcookie_test.go
  • middleware/requestid/requestid_test.go
  • middleware/expvar/expvar_test.go
  • router_test.go
  • middleware/timeout/timeout_test.go
  • middleware/cors/cors_test.go
  • app_test.go
  • bind_test.go
  • middleware/compress/compress_test.go
  • middleware/basicauth/basicauth_test.go
  • middleware/helmet/helmet_test.go
  • mount_test.go
  • middleware/etag/etag_test.go
  • middleware/static/static_test.go
  • middleware/skip/skip_test.go
📚 Learning: 2024-09-25T16:18:34.719Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/session/config.go:122-122
Timestamp: 2024-09-25T16:18:34.719Z
Learning: In `DefaultErrorHandler(c *fiber.Ctx, err error)`, since `c` is a pointer to an interface, we need to dereference `*c` when calling interface methods like `SendStatus`.

Applied to files:

  • middleware/pprof/pprof_test.go
  • middleware/cache/cache_test.go
  • middleware/logger/logger_test.go
  • middleware/limiter/limiter_test.go
  • middleware/proxy/proxy_test.go
  • middleware/logger/tags.go
  • middleware/adaptor/adaptor_test.go
  • middleware/expvar/expvar_test.go
  • middleware/compress/compress_test.go
  • middleware/keyauth/keyauth_test.go
  • middleware/basicauth/basicauth_test.go
  • middleware/rewrite/rewrite_test.go
  • mount_test.go
  • middleware/redirect/redirect_test.go
  • middleware/idempotency/idempotency_test.go
  • middleware/etag/etag_test.go
  • middleware/logger/default_logger.go
  • middleware/csrf/csrf_test.go
📚 Learning: 2025-10-16T07:15:26.529Z
Learnt from: grivera64
Repo: gofiber/fiber PR: 3807
File: adapter_test.go:118-144
Timestamp: 2025-10-16T07:15:26.529Z
Learning: In Fiber v3, net/http handlers (http.Handler, http.HandlerFunc, or raw func(http.ResponseWriter, *http.Request)) can be passed directly to routing methods like app.Get(), app.Post(), etc. The framework automatically detects and wraps them internally via toFiberHandler/collectHandlers. The github.com/gofiber/fiber/v3/middleware/adaptor package is legacy and should not be suggested for tests or code using native net/http handler support.

Applied to files:

  • middleware/pprof/pprof_test.go
  • middleware/favicon/favicon_test.go
  • middleware/cache/cache_test.go
  • middleware/logger/logger_test.go
  • middleware/recover/recover_test.go
  • middleware/limiter/limiter_test.go
  • middleware/proxy/proxy_test.go
  • middleware/basicauth/basicauth.go
  • middleware/envvar/envvar_test.go
  • middleware/earlydata/earlydata_test.go
  • ctx_test.go
  • middleware/encryptcookie/encryptcookie_test.go
  • middleware/adaptor/adaptor_test.go
  • middleware/requestid/requestid_test.go
  • middleware/expvar/expvar_test.go
  • middleware/limiter/limiter.go
  • middleware/logger/config.go
  • router_test.go
  • middleware/timeout/timeout_test.go
  • middleware/cors/cors_test.go
  • app_test.go
  • middleware/compress/compress_test.go
  • middleware/keyauth/keyauth_test.go
  • middleware/basicauth/basicauth_test.go
  • middleware/helmet/helmet_test.go
  • middleware/rewrite/rewrite_test.go
  • mount_test.go
  • middleware/redirect/redirect_test.go
  • middleware/idempotency/idempotency_test.go
  • middleware/etag/etag_test.go
  • middleware/static/static_test.go
  • middleware/skip/skip_test.go
  • middleware/csrf/csrf_test.go
📚 Learning: 2024-11-15T07:56:21.623Z
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.

Applied to files:

  • middleware/pprof/pprof_test.go
  • middleware/favicon/favicon_test.go
  • middleware/cache/cache_test.go
  • middleware/logger/logger_test.go
  • middleware/recover/recover_test.go
  • middleware/limiter/limiter_test.go
  • middleware/proxy/proxy_test.go
  • middleware/logger/utils.go
  • middleware/earlydata/earlydata_test.go
  • ctx_test.go
  • adapter_test.go
  • middleware/adaptor/adaptor_test.go
  • prefork_test.go
  • middleware/requestid/requestid_test.go
  • hooks_test.go
  • middleware/timeout/timeout_test.go
  • middleware/cors/cors_test.go
  • middleware/compress/compress_test.go
  • listen_test.go
  • middleware/keyauth/keyauth_test.go
  • middleware/basicauth/basicauth_test.go
  • middleware/helmet/helmet_test.go
  • middleware/rewrite/rewrite_test.go
  • mount_test.go
  • middleware/redirect/redirect_test.go
  • middleware/etag/etag_test.go
  • middleware/static/static_test.go
  • middleware/skip/skip_test.go
  • middleware/csrf/csrf_test.go
📚 Learning: 2024-10-08T19:06:06.583Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/csrf/csrf_test.go:188-193
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In the Fiber framework tests, using `ctx.Response.Header.Cookie` may not be suitable for parsing cookies from the response header, as it requires a `*Cookie` and fills it rather than returning a string value; thus, manual parsing of the `Set-Cookie` header may be necessary.

Applied to files:

  • middleware/favicon/favicon_test.go
  • middleware/cache/cache_test.go
  • middleware/logger/logger_test.go
  • middleware/proxy/proxy_test.go
  • redirect_test.go
  • middleware/earlydata/earlydata_test.go
  • middleware/encryptcookie/encryptcookie_test.go
  • middleware/adaptor/adaptor_test.go
  • middleware/expvar/expvar_test.go
  • middleware/compress/compress_test.go
  • middleware/keyauth/keyauth_test.go
  • middleware/basicauth/basicauth_test.go
  • middleware/helmet/helmet_test.go
  • middleware/redirect/redirect_test.go
  • middleware/static/static_test.go
  • middleware/csrf/csrf_test.go
📚 Learning: 2024-12-13T08:14:22.851Z
Learnt from: efectn
Repo: gofiber/fiber PR: 3162
File: hooks_test.go:228-228
Timestamp: 2024-12-13T08:14:22.851Z
Learning: In Go test files, prefer using the `require` methods from the `testify` package for assertions instead of manual comparisons and calls to `t.Fatal` or `t.Fatalf`.

Applied to files:

  • middleware/favicon/favicon_test.go
  • middleware/cache/cache_test.go
  • middleware/logger/logger_test.go
  • middleware/recover/recover_test.go
  • middleware/limiter/limiter_test.go
  • middleware/healthcheck/healthcheck_test.go
  • middleware/earlydata/earlydata_test.go
  • ctx_test.go
  • middleware/adaptor/adaptor_test.go
  • middleware/requestid/requestid_test.go
  • router_test.go
  • app_test.go
  • bind_test.go
  • middleware/compress/compress_test.go
  • middleware/keyauth/keyauth_test.go
  • middleware/redirect/redirect_test.go
  • middleware/static/static_test.go
  • middleware/skip/skip_test.go
📚 Learning: 2024-10-08T19:06:06.583Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/session/store.go:164-167
Timestamp: 2024-10-08T19:06:06.583Z
Learning: Unit tests in this project use testify require.

Applied to files:

  • middleware/favicon/favicon_test.go
  • middleware/cache/cache_test.go
  • middleware/logger/logger_test.go
  • middleware/recover/recover_test.go
  • middleware/limiter/limiter_test.go
  • middleware/healthcheck/healthcheck_test.go
  • middleware/earlydata/earlydata_test.go
  • ctx_test.go
  • middleware/encryptcookie/encryptcookie_test.go
  • middleware/requestid/requestid_test.go
  • middleware/expvar/expvar_test.go
  • router_test.go
  • middleware/timeout/timeout_test.go
  • app_test.go
  • bind_test.go
  • middleware/compress/compress_test.go
  • middleware/keyauth/keyauth_test.go
  • middleware/basicauth/basicauth_test.go
  • middleware/helmet/helmet_test.go
  • mount_test.go
  • middleware/redirect/redirect_test.go
  • middleware/etag/etag_test.go
  • middleware/static/static_test.go
  • middleware/skip/skip_test.go
  • middleware/csrf/csrf_test.go
📚 Learning: 2024-11-29T12:37:27.581Z
Learnt from: efectn
Repo: gofiber/fiber PR: 3162
File: app_test.go:893-895
Timestamp: 2024-11-29T12:37:27.581Z
Learning: In the `Test_App_ShutdownWithContext` function in `app_test.go`, the `clientDone` channel is used to synchronize the client's request completion before proceeding, eliminating the need for additional `time.Sleep` calls.

Applied to files:

  • middleware/cache/cache_test.go
  • middleware/logger/logger_test.go
  • middleware/limiter/limiter_test.go
  • middleware/proxy/proxy_test.go
  • ctx_test.go
  • middleware/requestid/requestid_test.go
  • router_test.go
  • middleware/timeout/timeout_test.go
  • app_test.go
  • middleware/keyauth/keyauth_test.go
  • middleware/basicauth/basicauth_test.go
  • mount_test.go
  • listen.go
  • middleware/static/static_test.go
📚 Learning: 2024-09-25T17:05:06.991Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/session/middleware_test.go:190-191
Timestamp: 2024-09-25T17:05:06.991Z
Learning: When testing session `IdleTimeout` expiration, it's acceptable to use `time.Sleep` to simulate the passage of time in tests.

Applied to files:

  • middleware/cache/cache_test.go
  • middleware/logger/logger_test.go
  • middleware/proxy/proxy_test.go
  • middleware/timeout/timeout_test.go
  • app_test.go
📚 Learning: 2024-11-10T23:44:13.704Z
Learnt from: gaby
Repo: gofiber/fiber PR: 3193
File: middleware/adaptor/adaptor.go:111-111
Timestamp: 2024-11-10T23:44:13.704Z
Learning: In the `middleware/adaptor/adaptor.go` file of the Fiber framework, when updating context handling, replacing `c.Context()` with `c.RequestCtx()` is appropriate to access the `fasthttp.RequestCtx`.

Applied to files:

  • middleware/logger/logger_test.go
  • middleware/envvar/envvar_test.go
  • middleware/adaptor/adaptor_test.go
  • middleware/requestid/requestid_test.go
  • middleware/timeout/timeout_test.go
  • middleware/keyauth/keyauth_test.go
  • middleware/basicauth/basicauth_test.go
  • middleware/rewrite/rewrite_test.go
  • middleware/redirect/redirect_test.go
  • extractors/extractors_test.go
📚 Learning: 2025-05-08T08:14:37.302Z
Learnt from: mdelapenya
Repo: gofiber/fiber PR: 3434
File: app.go:623-636
Timestamp: 2025-05-08T08:14:37.302Z
Learning: In the gofiber/fiber framework, service startup failures should panic rather than allowing the application to continue running with degraded functionality, as this is the agreed-upon design decision.

Applied to files:

  • middleware/recover/recover_test.go
📚 Learning: 2025-07-27T17:28:53.403Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3625
File: middleware/session/config.go:57-58
Timestamp: 2025-07-27T17:28:53.403Z
Learning: In the session middleware `Config` struct, the `Extractor` field uses function closures (like `FromCookie(key)`), making it impossible to introspect extractor parameters at runtime for validation purposes without complex reflection techniques.

Applied to files:

  • middleware/csrf/config.go
  • middleware/csrf/csrf.go
📚 Learning: 2024-10-08T19:06:06.583Z
Learnt from: gaby
Repo: gofiber/fiber PR: 3056
File: middleware/encryptcookie/utils.go:22-25
Timestamp: 2024-10-08T19:06:06.583Z
Learning: The `encryptcookie_test.go` file contains unit tests that validate key lengths for both `EncryptCookie` and `DecryptCookie` functions, ensuring that invalid key lengths raise appropriate errors.

Applied to files:

  • middleware/encryptcookie/encryptcookie_test.go
📚 Learning: 2024-07-01T03:44:03.672Z
Learnt from: gaby
Repo: gofiber/fiber PR: 3056
File: middleware/encryptcookie/utils.go:20-23
Timestamp: 2024-07-01T03:44:03.672Z
Learning: Unit tests for key length enforcement in both `EncryptCookie` and `DecryptCookie` functions have been added to ensure robust validation and prevent potential runtime errors.

Applied to files:

  • middleware/encryptcookie/encryptcookie_test.go
📚 Learning: 2024-10-08T19:06:06.583Z
Learnt from: gaby
Repo: gofiber/fiber PR: 3056
File: middleware/encryptcookie/utils.go:51-54
Timestamp: 2024-10-08T19:06:06.583Z
Learning: Unit tests for key length enforcement in `DecryptCookie` have been added to ensure consistency and security in the encryption processes.

Applied to files:

  • middleware/encryptcookie/encryptcookie_test.go
📚 Learning: 2024-10-08T19:06:06.583Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3051
File: middleware/session/session.go:215-216
Timestamp: 2024-10-08T19:06:06.583Z
Learning: Parallel tests for `Session.Save` already exist in the `middleware/session/session_test.go` file, specifically in the `Test_Session_Save` and `Test_Session_Save_Expiration` functions.

Applied to files:

  • app_test.go
  • middleware/csrf/csrf_test.go
📚 Learning: 2024-11-08T04:10:42.990Z
Learnt from: gaby
Repo: gofiber/fiber PR: 3193
File: middleware/cache/cache_test.go:897-897
Timestamp: 2024-11-08T04:10:42.990Z
Learning: In the Fiber framework, `Context()` is being renamed to `RequestCtx()`, and `UserContext()` to `Context()` to improve clarity and align with Go's context conventions.

Applied to files:

  • middleware/basicauth/basicauth_test.go
📚 Learning: 2024-09-25T16:17:00.969Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/session/config.go:16-26
Timestamp: 2024-09-25T16:17:00.969Z
Learning: In the session middleware `Config` struct, `Store` is backed by `fiber.Storage`; they are different entities serving distinct purposes in session management.

Applied to files:

  • middleware/session/middleware.go
  • middleware/csrf/csrf.go
  • middleware/csrf/csrf_test.go
📚 Learning: 2024-09-25T16:15:39.392Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/csrf/session_manager.go:30-43
Timestamp: 2024-09-25T16:15:39.392Z
Learning: In the session middleware, `session.FromContext(c)` returns `*session.Middleware`, whereas `m.session.Get(c)` returns `*session.Store`, so they are not directly interchangeable.

Applied to files:

  • middleware/session/middleware.go
  • middleware/csrf/csrf.go
  • middleware/csrf/csrf_test.go
📚 Learning: 2024-10-08T19:06:06.583Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/csrf/csrf_test.go:164-165
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In the `Test_CSRF_WithSession_Middleware` function, calling `session.NewWithStore()` without arguments is acceptable, as the default configuration is sufficient.

Applied to files:

  • middleware/session/middleware.go
  • middleware/csrf/csrf_test.go
📚 Learning: 2025-10-22T13:48:12.485Z
Learnt from: CR
Repo: gofiber/fiber PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-22T13:48:12.485Z
Learning: Run tests with gotestsum (Make target: test)

Applied to files:

  • middleware/skip/skip_test.go
🧬 Code graph analysis (51)
middleware/pprof/pprof_test.go (1)
constants.go (1)
  • MethodGet (5-5)
middleware/cache/cache_test.go (1)
constants.go (5)
  • MethodGet (5-5)
  • MethodPost (7-7)
  • HeaderCacheControl (168-168)
  • MethodHead (6-6)
  • HeaderAge (167-167)
middleware/logger/logger_test.go (2)
constants.go (3)
  • MethodGet (5-5)
  • StatusOK (52-52)
  • MethodPost (7-7)
app.go (1)
  • TestConfig (1093-1104)
middleware/recover/recover_test.go (1)
constants.go (1)
  • MethodGet (5-5)
middleware/proxy/proxy_test.go (2)
constants.go (1)
  • MethodGet (5-5)
app.go (1)
  • TestConfig (1093-1104)
middleware/logger/tags.go (2)
middleware/logger/config.go (2)
  • Buffer (108-119)
  • Config (12-99)
ctx_interface_gen.go (1)
  • Ctx (18-431)
res_interface_gen.go (2)
router.go (1)
  • Route (43-64)
app.go (1)
  • Map (43-43)
middleware/basicauth/basicauth.go (2)
middleware/csrf/csrf.go (2)
  • New (47-214)
  • Handler (30-34)
middleware/limiter/limiter.go (2)
  • New (23-29)
  • Handler (18-20)
middleware/proxy/proxy.go (1)
middleware/proxy/config.go (1)
  • Config (12-70)
middleware/healthcheck/healthcheck_test.go (1)
constants.go (3)
  • MethodGet (5-5)
  • MethodPost (7-7)
  • StatusMethodNotAllowed (78-78)
middleware/envvar/envvar_test.go (1)
constants.go (3)
  • MethodGet (5-5)
  • MethodPost (7-7)
  • MethodHead (6-6)
redirect_test.go (1)
constants.go (1)
  • MethodGet (5-5)
middleware/logger/utils.go (1)
color.go (1)
  • Colors (8-53)
middleware/earlydata/earlydata_test.go (1)
constants.go (2)
  • MethodGet (5-5)
  • MethodPost (7-7)
ctx_test.go (2)
constants.go (3)
  • MethodGet (5-5)
  • StatusOK (52-52)
  • HeaderContentDisposition (211-211)
app.go (2)
  • Map (43-43)
  • ErrTestGotEmptyResponse (1090-1090)
res.go (3)
router.go (1)
  • Route (43-64)
app.go (1)
  • Map (43-43)
extractors/extractors.go (1)
  • ErrNotFound (64-64)
prefork.go (1)
listen.go (3)
  • App (287-324)
  • App (342-360)
  • ListenConfig (42-125)
adapter_test.go (2)
constants.go (1)
  • MethodGet (5-5)
app.go (1)
  • TestConfig (1093-1104)
middleware/encryptcookie/encryptcookie_test.go (1)
constants.go (1)
  • MethodGet (5-5)
middleware/adaptor/adaptor_test.go (2)
constants.go (2)
  • MethodGet (5-5)
  • MethodPost (7-7)
app.go (1)
  • TestConfig (1093-1104)
prefork_test.go (2)
listen.go (1)
  • ListenConfig (42-125)
constants.go (1)
  • NetworkTCP6 (293-293)
middleware/requestid/requestid_test.go (1)
constants.go (3)
  • MethodGet (5-5)
  • StatusOK (52-52)
  • HeaderXRequestID (281-281)
hooks.go (1)
router.go (1)
  • Route (43-64)
middleware/expvar/expvar_test.go (1)
constants.go (1)
  • MethodGet (5-5)
middleware/limiter/limiter.go (1)
middleware/limiter/config.go (1)
  • Config (10-75)
middleware/logger/config.go (2)
middleware/cache/config.go (1)
  • Config (11-80)
middleware/logger/data.go (1)
  • Data (9-18)
hooks_test.go (2)
listen.go (1)
  • ListenConfig (42-125)
router.go (1)
  • Route (43-64)
middleware/timeout/timeout_test.go (1)
constants.go (1)
  • MethodGet (5-5)
app_test.go (1)
app.go (2)
  • TestConfig (1093-1104)
  • Config (115-426)
bind_test.go (1)
constants.go (1)
  • MethodGet (5-5)
middleware/compress/compress_test.go (1)
constants.go (2)
  • MethodGet (5-5)
  • MethodHead (6-6)
ctx_interface_gen.go (2)
router.go (1)
  • Route (43-64)
app.go (1)
  • Map (43-43)
middleware/keyauth/keyauth_test.go (1)
constants.go (1)
  • MethodGet (5-5)
middleware/basicauth/basicauth_test.go (1)
constants.go (1)
  • MethodGet (5-5)
middleware/helmet/helmet_test.go (1)
constants.go (2)
  • MethodGet (5-5)
  • HeaderReferrerPolicy (229-229)
middleware/rewrite/rewrite_test.go (1)
constants.go (1)
  • MethodGet (5-5)
mount_test.go (1)
constants.go (3)
  • MethodGet (5-5)
  • StatusOK (52-52)
  • MethodPost (7-7)
services.go (1)
color.go (2)
  • Colors (8-53)
  • DefaultColors (56-66)
middleware/redirect/redirect_test.go (1)
constants.go (1)
  • MethodGet (5-5)
middleware/session/middleware.go (1)
middleware/session/config.go (1)
  • Config (13-90)
redirect.go (2)
app.go (1)
  • App (68-112)
router.go (1)
  • App (376-396)
listen.go (1)
hooks.go (1)
  • ListenData (46-50)
middleware/idempotency/idempotency_test.go (1)
middleware/idempotency/config.go (1)
  • ConfigDefault (58-81)
middleware/csrf/csrf.go (1)
middleware/csrf/config.go (1)
  • Config (16-126)
middleware/limiter/limiter_sliding.go (2)
middleware/limiter/limiter.go (2)
  • New (23-29)
  • Handler (18-20)
middleware/limiter/config.go (1)
  • Config (10-75)
middleware/etag/etag_test.go (1)
constants.go (2)
  • MethodGet (5-5)
  • MethodPut (8-8)
middleware/limiter/limiter_fixed.go (2)
middleware/limiter/limiter.go (2)
  • New (23-29)
  • Handler (18-20)
middleware/limiter/config.go (1)
  • Config (10-75)
middleware/cors/cors.go (2)
middleware/cors/config.go (1)
  • Config (8-79)
constants.go (1)
  • HeaderAccessControlMaxAge (203-203)
middleware/logger/default_logger.go (2)
middleware/logger/config.go (1)
  • Config (12-99)
middleware/logger/format.go (1)
  • DefaultFormat (5-5)
middleware/skip/skip_test.go (1)
constants.go (1)
  • MethodGet (5-5)
middleware/csrf/csrf_test.go (2)
middleware/csrf/config.go (1)
  • Config (16-126)
middleware/session/config.go (1)
  • Config (13-90)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: assign-v3
  • GitHub Check: unit (1.25.x, windows-latest)
  • GitHub Check: lint
  • GitHub Check: Compare
  • GitHub Check: repeated

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
res.go (1)

609-610: Route not found returns empty Route, not error.

When app.GetRoute(routeName) doesn't find a route, it returns a zero-value Route{} rather than an error. This means:

  1. &route will never be nil
  2. The zero-value Route has empty routeParser.segs, so getLocationFromRoute returns an empty string with no error

If the intent is to return ErrNotFound when a route doesn't exist, consider checking if the route is valid (e.g., route.Path == ""):

route := r.c.app.GetRoute(routeName)
if route.Path == "" {
    return "", ErrNotFound
}
return r.getLocationFromRoute(&route, params)

However, this changes existing behavior, so only apply if that's the desired outcome.

🧹 Nitpick comments (4)
client/client_test.go (2)

53-55: Simplify the channel receive assignment.

The intermediate variable received is unnecessary. Direct assignment to the named return variable is clearer and more idiomatic.

Apply this diff to simplify:

 	select {
-	case received := <-addrChan:
-		addr = received
+	case addr = <-addrChan:
 		return app, addr

60-60: Remove unreachable return statement.

This return statement is unreachable because t.Fatalf on line 57 terminates the test. The line can be safely removed.

Apply this diff:

 	case err := <-errChan:
 		t.Fatalf("Failed to start test server: %v", err)
 	}
-
-	return nil, ""
 }
ctx_test.go (1)

22-31: http.NoBody adoption in tests: LGTM

The replacements are correct and align with linter expectations.

For consistency and resource hygiene, consider adding t.Cleanup(func(){ _ = resp.Body.Close() }) after app.Test(...) in spots that read the body but don’t already close it.

Also applies to: 167-174, 192-207, 257-265, 3690-3694

middleware/idempotency/idempotency_test.go (1)

225-240: Close response body in helper to avoid leaks

do() reads the body but never closes it. Safe to close before returning since callers only read headers/status.

-func do(app *fiber.App, req *http.Request) (resp *http.Response, body string) {
-	var err error
-	resp, err = app.Test(req, fiber.TestConfig{Timeout: 5 * time.Second})
+func do(app *fiber.App, req *http.Request) (resp *http.Response, body string) {
+	var err error
+	resp, err = app.Test(req, fiber.TestConfig{Timeout: 5 * time.Second})
 	if err != nil {
 		panic(err)
 	}
-	var payload []byte
-	payload, err = io.ReadAll(resp.Body)
+	defer func() { _ = resp.Body.Close() }()
+	payload, err := io.ReadAll(resp.Body)
 	if err != nil {
 		panic(err)
 	}
-	body = string(payload)
-	return resp, body
+	return resp, string(payload)
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb29c53 and 578b96c.

📒 Files selected for processing (25)
  • app.go (3 hunks)
  • app_test.go (47 hunks)
  • client/client_test.go (2 hunks)
  • client/helper_test.go (1 hunks)
  • ctx.go (1 hunks)
  • ctx_interface_gen.go (2 hunks)
  • ctx_test.go (52 hunks)
  • extractors/extractors.go (1 hunks)
  • helpers.go (5 hunks)
  • internal/storage/memory/memory.go (3 hunks)
  • internal/tlstest/tls.go (3 hunks)
  • middleware/adaptor/adaptor_test.go (10 hunks)
  • middleware/cache/heap.go (1 hunks)
  • middleware/cors/utils.go (2 hunks)
  • middleware/csrf/helpers.go (1 hunks)
  • middleware/idempotency/idempotency_test.go (12 hunks)
  • middleware/logger/tags.go (2 hunks)
  • middleware/proxy/proxy_test.go (35 hunks)
  • middleware/static/static.go (1 hunks)
  • mount_test.go (18 hunks)
  • path.go (1 hunks)
  • req.go (7 hunks)
  • req_interface_gen.go (1 hunks)
  • res.go (5 hunks)
  • router.go (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • middleware/logger/tags.go
  • app_test.go
  • middleware/proxy/proxy_test.go
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

**/*.go: Apply formatting using gofumpt (Make target: format)
Optimize struct field alignment using betteralign (Make target: betteralign)
Modernize code using gopls modernize (Make target: modernize)

Files:

  • extractors/extractors.go
  • internal/storage/memory/memory.go
  • middleware/csrf/helpers.go
  • middleware/idempotency/idempotency_test.go
  • router.go
  • ctx.go
  • middleware/cors/utils.go
  • middleware/cache/heap.go
  • ctx_interface_gen.go
  • res.go
  • client/client_test.go
  • ctx_test.go
  • middleware/adaptor/adaptor_test.go
  • internal/tlstest/tls.go
  • helpers.go
  • path.go
  • app.go
  • req.go
  • middleware/static/static.go
  • req_interface_gen.go
  • client/helper_test.go
  • mount_test.go
🧠 Learnings (13)
📓 Common learnings
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.
Learnt from: grivera64
Repo: gofiber/fiber PR: 3807
File: adapter_test.go:118-144
Timestamp: 2025-10-16T07:19:52.418Z
Learning: In the Fiber codebase, the linter does not allow `require` assertions from within HTTP handlers (including net/http-style handlers). Use `t.Fatalf`, `t.Errorf`, or similar `testing.T` methods for error handling inside handler functions instead.
📚 Learning: 2025-10-16T07:19:52.418Z
Learnt from: grivera64
Repo: gofiber/fiber PR: 3807
File: adapter_test.go:118-144
Timestamp: 2025-10-16T07:19:52.418Z
Learning: In the Fiber codebase, the linter does not allow `require` assertions from within HTTP handlers (including net/http-style handlers). Use `t.Fatalf`, `t.Errorf`, or similar `testing.T` methods for error handling inside handler functions instead.

Applied to files:

  • middleware/idempotency/idempotency_test.go
  • client/client_test.go
  • ctx_test.go
  • middleware/adaptor/adaptor_test.go
  • client/helper_test.go
  • mount_test.go
📚 Learning: 2024-11-29T12:37:27.581Z
Learnt from: efectn
Repo: gofiber/fiber PR: 3162
File: app_test.go:893-895
Timestamp: 2024-11-29T12:37:27.581Z
Learning: In the `Test_App_ShutdownWithContext` function in `app_test.go`, the `clientDone` channel is used to synchronize the client's request completion before proceeding, eliminating the need for additional `time.Sleep` calls.

Applied to files:

  • middleware/idempotency/idempotency_test.go
  • client/client_test.go
  • ctx_test.go
  • mount_test.go
📚 Learning: 2025-10-16T07:15:26.529Z
Learnt from: grivera64
Repo: gofiber/fiber PR: 3807
File: adapter_test.go:118-144
Timestamp: 2025-10-16T07:15:26.529Z
Learning: In Fiber v3, net/http handlers (http.Handler, http.HandlerFunc, or raw func(http.ResponseWriter, *http.Request)) can be passed directly to routing methods like app.Get(), app.Post(), etc. The framework automatically detects and wraps them internally via toFiberHandler/collectHandlers. The github.com/gofiber/fiber/v3/middleware/adaptor package is legacy and should not be suggested for tests or code using native net/http handler support.

Applied to files:

  • middleware/idempotency/idempotency_test.go
  • router.go
  • ctx_test.go
  • middleware/adaptor/adaptor_test.go
  • client/helper_test.go
  • mount_test.go
📚 Learning: 2024-09-25T17:09:03.756Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/session/middleware_test.go:400-407
Timestamp: 2024-09-25T17:09:03.756Z
Learning: In the `Test_Session_Next` function in `middleware/session/middleware_test.go`, the variable `doNext` is properly synchronized with the `muNext` mutex for both read and write access.

Applied to files:

  • middleware/idempotency/idempotency_test.go
📚 Learning: 2024-09-25T16:18:34.719Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/session/config.go:122-122
Timestamp: 2024-09-25T16:18:34.719Z
Learning: In `DefaultErrorHandler(c *fiber.Ctx, err error)`, since `c` is a pointer to an interface, we need to dereference `*c` when calling interface methods like `SendStatus`.

Applied to files:

  • middleware/idempotency/idempotency_test.go
  • middleware/adaptor/adaptor_test.go
  • middleware/static/static.go
  • mount_test.go
📚 Learning: 2024-11-15T07:56:21.623Z
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.

Applied to files:

  • client/client_test.go
  • middleware/adaptor/adaptor_test.go
  • client/helper_test.go
  • mount_test.go
📚 Learning: 2024-11-10T23:44:13.704Z
Learnt from: gaby
Repo: gofiber/fiber PR: 3193
File: middleware/adaptor/adaptor.go:111-111
Timestamp: 2024-11-10T23:44:13.704Z
Learning: In the `middleware/adaptor/adaptor.go` file of the Fiber framework, when updating context handling, replacing `c.Context()` with `c.RequestCtx()` is appropriate to access the `fasthttp.RequestCtx`.

Applied to files:

  • ctx_test.go
  • middleware/adaptor/adaptor_test.go
📚 Learning: 2024-10-02T23:03:31.727Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/session/store.go:164-167
Timestamp: 2024-10-02T23:03:31.727Z
Learning: Unit tests in this project use testify require.

Applied to files:

  • ctx_test.go
  • mount_test.go
📚 Learning: 2024-12-13T08:14:22.851Z
Learnt from: efectn
Repo: gofiber/fiber PR: 3162
File: hooks_test.go:228-228
Timestamp: 2024-12-13T08:14:22.851Z
Learning: In Go test files, prefer using the `require` methods from the `testify` package for assertions instead of manual comparisons and calls to `t.Fatal` or `t.Fatalf`.

Applied to files:

  • ctx_test.go
  • middleware/adaptor/adaptor_test.go
📚 Learning: 2024-10-08T19:06:06.583Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 2922
File: middleware/cors/utils.go:63-71
Timestamp: 2024-10-08T19:06:06.583Z
Learning: The project uses the testify/assert package for assertions in unit tests.

Applied to files:

  • ctx_test.go
  • mount_test.go
📚 Learning: 2024-10-08T19:06:06.583Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/csrf/csrf_test.go:188-193
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In the Fiber framework tests, using `ctx.Response.Header.Cookie` may not be suitable for parsing cookies from the response header, as it requires a `*Cookie` and fills it rather than returning a string value; thus, manual parsing of the `Set-Cookie` header may be necessary.

Applied to files:

  • middleware/adaptor/adaptor_test.go
  • middleware/static/static.go
📚 Learning: 2025-09-18T00:32:59.671Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 0
File: :0-0
Timestamp: 2025-09-18T00:32:59.671Z
Learning: In Go 1.22, manual copying of loop variables (like `x := x`) is no longer necessary due to the fix for variable capture in closures. Each loop iteration now creates its own instance of the loop variable automatically.

Applied to files:

  • path.go
🧬 Code graph analysis (7)
middleware/idempotency/idempotency_test.go (2)
app.go (1)
  • TestConfig (1093-1104)
middleware/idempotency/config.go (1)
  • ConfigDefault (58-81)
ctx_interface_gen.go (2)
router.go (1)
  • Route (43-64)
app.go (1)
  • Map (43-43)
res.go (3)
router.go (1)
  • Route (43-64)
app.go (1)
  • Map (43-43)
extractors/extractors.go (1)
  • ErrNotFound (64-64)
ctx_test.go (2)
constants.go (1)
  • MethodGet (5-5)
app.go (2)
  • Map (43-43)
  • ErrTestGotEmptyResponse (1090-1090)
middleware/adaptor/adaptor_test.go (2)
constants.go (2)
  • MethodGet (5-5)
  • MethodPost (7-7)
app.go (1)
  • TestConfig (1093-1104)
req.go (1)
constants.go (1)
  • HeaderXForwardedHost (220-220)
client/helper_test.go (1)
listen.go (3)
  • App (287-324)
  • App (342-360)
  • ListenConfig (42-125)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Compare
  • GitHub Check: repeated
  • GitHub Check: unit (1.25.x, windows-latest)
  • GitHub Check: unit (1.25.x, macos-latest)
  • GitHub Check: unit (1.25.x, macos-13)
  • GitHub Check: lint
🔇 Additional comments (35)
middleware/static/static.go (1)

205-205: LGTM! Idiomatic empty string check.

The change to use != "" instead of len(cacheControlValue) > 0 is more idiomatic in Go and improves readability while maintaining identical behavior.

middleware/cors/utils.go (2)

21-21: LGTM! Idiomatic empty-string check.

The change from len(input) > 0 to input != "" is more idiomatic in Go and aligns with the modernization objectives of this PR.


34-34: LGTM! Named return values improve clarity.

The addition of named return values (valid bool, normalized string) makes the function signature self-documenting and improves code readability. The implementation correctly uses explicit returns throughout.

middleware/cache/heap.go (3)

84-87: LGTM! Named return parameters improve documentation.

The addition of named return parameters makes the function signature self-documenting, clarifying that the method returns the cache key and entry size.


90-92: LGTM! Consistent with the other removal methods.

The named return parameters maintain consistency with removeInternal and clearly document the method's return values.


95-97: LGTM! Completes the consistent signature pattern.

The named return parameters are consistent with the other removal methods, making the API more uniform and self-documenting.

client/client_test.go (1)

29-32: LGTM! Correct use of named return values.

The function signature now uses named return values, and the assignment on line 32 correctly uses = instead of := to avoid shadowing the named return parameter app.

client/helper_test.go (1)

73-88: LGTM! Named returns improve clarity.

The refactor to named return values is correct and makes the function signature more self-documenting. The implementation properly assigns to the named returns (app = fiber.New() instead of app :=), and the closures correctly capture the necessary variables. The explicit return statement maintains clarity even though naked return could be used.

mount_test.go (1)

25-31: Use of http.NoBody in tests: LGTM

Switching nil bodies to http.NoBody matches gocritic httpNoBody guidance and keeps semantics.

Also applies to: 47-51, 77-90, 100-137, 144-151

internal/storage/memory/memory.go (1)

52-55: Idiom improvement for empty key checks

key == "" is clearer than len(key) == 0. Behavior preserved.

Also applies to: 80-83, 112-115

middleware/csrf/helpers.go (1)

21-48: Named return values: OK

Switching to named returns improves clarity without changing behavior. Origin validation/normalization logic remains sound.

middleware/idempotency/idempotency_test.go (1)

83-97: http.NoBody usage: LGTM

The move to http.NoBody across requests is correct and aligns with gocritic httpNoBody.

Also applies to: 254-264, 272-279, 287-294, 302-309, 328-343, 352-363, 372-378, 400-405, 415-420

path.go (1)

215-226: Loop condition change is approved; Go version compatibility confirmed

for pattern != "" is semantically correct and clear. The module's Go version (1.25.0) fully supports all modern constructs used in the codebase, including integer-range loops like for i := range segLen at path.go:262. No compatibility issues will arise.

req_interface_gen.go (1)

33-39: Verification complete: interface signature is compatible with implementation

The implementation in req.go:84 matches the interface signatures in both req_interface_gen.go:33 and ctx_interface_gen.go:187. Named return values don't affect Go's type identity, and the single implementation found compiles correctly with the interface signature. No breaking changes.

ctx_interface_gen.go (2)

187-187: LGTM! Named return values improve clarity.

The addition of named return values (body []byte, decodesRealized uint8, err error) enhances readability without changing behavior.


376-376: LGTM! Pointer parameter reduces memory overhead.

Changing the route parameter from Route to *Route addresses the gocritic hugeParam issue by avoiding a struct copy. The Route struct contains multiple fields and slices, making pointer passing more efficient.

ctx.go (1)

408-408: LGTM! More idiomatic empty string check.

The change from len(token) == 0 to token == "" is a style improvement with no behavioral change. Both are functionally equivalent, but the latter is more idiomatic in Go.

internal/tlstest/tls.go (1)

20-20: LGTM! Named return values improve clarity.

The refactor to use named return values (serverTLSConf and clientTLSConf) is implemented correctly:

  • Signature declares the named returns
  • Assignments changed from := to = to properly assign to the named variables
  • Behavior remains unchanged

This makes the function's return contract more explicit.

Also applies to: 119-119, 128-128

middleware/adaptor/adaptor_test.go (1)

225-225: LGTM! Correctly addresses gocritic httpNoBody check.

Replacing nil with http.NoBody for requests without a body is the correct fix for the gocritic httpNoBody linter check. http.NoBody is more explicit and semantically correct, indicating an intentionally empty body rather than an uninitialized value.

All changes are in test code with no behavioral impact on test outcomes.

Also applies to: 253-253, 345-345, 354-354, 399-399, 423-423, 434-434, 675-675, 796-796

helpers.go (3)

168-168: LGTM! More idiomatic empty string checks.

The changes from len(value) == 0 and len(path) == 0 to value == "" and path == "" are style improvements with no behavioral changes. The latter form is more idiomatic in Go.

Also applies to: 175-175


616-626: LGTM! Named return values improve clarity.

The refactor to use named return values for normalizeEtag is implemented correctly:

  • Line 616: Signature declares named returns (value string, weak bool, ok bool)
  • Line 617: Assignment to weak uses = correctly
  • Return statements properly return the named values

This makes the function's contract more explicit.


689-722: LGTM! Named return values implemented correctly.

The refactor to use named return values for parseAddr is correct:

  • Line 689: Signature declares (host string, port string)
  • Lines 699, 709: Assignments use = to assign to named return variables
  • All return paths correctly return or assign the named variables

This improves code clarity without changing behavior.

res.go (3)

143-143: LGTM! More idiomatic empty string check.

The change from len(h) == 0 to h == "" is a style improvement with no behavioral change.


574-577: Nil check is necessary but consider edge cases.

The nil check prevents panics when getLocationFromRoute is called with a nil pointer, which is good defensive programming. However, note that GetRouteURL (line 609) calls app.GetRoute(routeName) which returns a zero-value Route{} (not nil) when the route is not found, then passes &route to this function.

For that call path:

  • A zero-value Route will have an empty routeParser.segs slice
  • The loop at line 581 will iterate zero times (safe)
  • The function will return an empty location string (line 601)

The nil check protects against direct calls with nil, which is appropriate for a public method.


797-799: LGTM! Idiomatic empty string checks.

The changes to use file == "" and cacheControlValue != "" instead of length checks are more idiomatic with no behavioral changes.

Also applies to: 849-849

extractors/extractors.go (1)

130-130: LGTM! More idiomatic empty string check.

The change from len(rest) == 0 to rest == "" is a style improvement with no behavioral change. The latter is more idiomatic in Go.

app.go (3)

629-629: LGTM! Pointer parameter avoids struct copy.

Passing &app.config.ColorScheme as a pointer to defaultColors addresses the gocritic hugeParam issue by avoiding a copy of the ColorScheme struct. This aligns with the broader refactor to use pointer parameters for large structs.


650-650: LGTM! More idiomatic empty string check.

The change from len(s) == 0 to s == "" is a style improvement with no behavioral change.


740-740: LGTM! Pointer parameter matches updated hook signature.

Passing app.latestRoute (which is *Route) to executeOnNameHooks is correct, as the hook signature was updated to accept *Route instead of Route as part of the hugeParam fixes.

router.go (3)

96-96: LGTM: Idiomatic string empty check.

The change from len(detectionPath) > 0 to detectionPath != "" is a more idiomatic Go pattern for checking non-empty strings while preserving the same logic.


520-520: LGTM: More idiomatic nil check.

Changing from nil == h to h == nil follows Go conventions by avoiding Yoda-style conditionals.


616-616: Code changes verified—no issues found.

The executeOnRouteHooks signature has been correctly updated to accept *Route (line 140 in hooks.go). Both calls at lines 616 and 679 in router.go correctly pass route pointers directly without dereferencing, which aligns with the PR's goal of avoiding large struct copies.

req.go (3)

87-87: LGTM: Named return values improve clarity.

Adding named return values provides better documentation without changing behavior. All return statements remain explicit, which is good practice.


146-146: LGTM: Idiomatic string emptiness checks.

The changes from len(str) > 0 / len(str) == 0 to direct string comparison (str != "" / str == "") are idiomatic Go patterns that improve readability while preserving the same logic.

Also applies to: 317-317, 353-353, 586-586


410-410: LGTM: Label removal is correct.

Removing the Local label from continue statements is appropriate since these are within the innermost loops. The plain continue statements correctly skip to the next iteration.

Also applies to: 462-462

github-actions[bot]

This comment was marked as outdated.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
middleware/cache/heap.go (1)

84-84: Minor: Inconsistent nolint comment wording.

The nolint comment here says "when removing heap entries" while the similar comments on lines 90 and 95 say "when removing" or just describe the "returned key and size pair." Consider standardizing the wording for consistency.

-func (h *indexedHeap) removeInternal(realIdx int) (key string, size uint) { //nolint:nonamedreturns // gocritic unnamedResult prefers named key and size when removing heap entries
+func (h *indexedHeap) removeInternal(realIdx int) (key string, size uint) { //nolint:nonamedreturns // gocritic unnamedResult prefers naming returned key and size pair
client/client_test.go (1)

52-60: Remove unreachable return statement.

Lines 59-60 contain an unreachable return nil, "" statement since both branches of the select (line 54 and line 56) exit the function. This dead code should be removed for clarity.

Apply this diff to remove the unreachable code:

 	select {
 	case addr = <-addrChan:
 		return app, addr
 	case err := <-errChan:
 		t.Fatalf("Failed to start test server: %v", err)
 	}
-
-	return nil, ""
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f3f20d3 and d02760d.

📒 Files selected for processing (12)
  • client/client_test.go (2 hunks)
  • client/helper_test.go (1 hunks)
  • ctx_interface_gen.go (2 hunks)
  • helpers.go (5 hunks)
  • internal/tlstest/tls.go (3 hunks)
  • middleware/cache/heap.go (1 hunks)
  • middleware/cors/utils.go (2 hunks)
  • middleware/csrf/helpers.go (1 hunks)
  • middleware/idempotency/idempotency_test.go (12 hunks)
  • middleware/proxy/proxy_test.go (35 hunks)
  • req.go (8 hunks)
  • req_interface_gen.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • middleware/cors/utils.go
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

**/*.go: Apply formatting using gofumpt (Make target: format)
Optimize struct field alignment using betteralign (Make target: betteralign)
Modernize code using gopls modernize (Make target: modernize)

Files:

  • middleware/cache/heap.go
  • ctx_interface_gen.go
  • req_interface_gen.go
  • internal/tlstest/tls.go
  • req.go
  • helpers.go
  • client/client_test.go
  • middleware/csrf/helpers.go
  • client/helper_test.go
  • middleware/proxy/proxy_test.go
  • middleware/idempotency/idempotency_test.go
🧠 Learnings (10)
📓 Common learnings
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 2864
File: ctx_test.go:4816-4816
Timestamp: 2024-10-08T19:06:06.583Z
Learning: The `ParamsInt` function's behavior, including handling empty string parameters, will be addressed in future PRs as per ReneWerner87's guidance.
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 2864
File: ctx_test.go:4816-4816
Timestamp: 2024-07-26T21:00:12.902Z
Learning: The `ParamsInt` function's behavior, including handling empty string parameters, will be addressed in future PRs as per ReneWerner87's guidance.
📚 Learning: 2025-10-22T13:48:12.485Z
Learnt from: CR
Repo: gofiber/fiber PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-22T13:48:12.485Z
Learning: Applies to **/*.go : Modernize code using gopls modernize (Make target: modernize)

Applied to files:

  • helpers.go
📚 Learning: 2024-11-15T07:56:21.623Z
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.

Applied to files:

  • client/client_test.go
  • client/helper_test.go
  • middleware/proxy/proxy_test.go
📚 Learning: 2024-11-29T12:37:27.581Z
Learnt from: efectn
Repo: gofiber/fiber PR: 3162
File: app_test.go:893-895
Timestamp: 2024-11-29T12:37:27.581Z
Learning: In the `Test_App_ShutdownWithContext` function in `app_test.go`, the `clientDone` channel is used to synchronize the client's request completion before proceeding, eliminating the need for additional `time.Sleep` calls.

Applied to files:

  • client/client_test.go
  • middleware/proxy/proxy_test.go
  • middleware/idempotency/idempotency_test.go
📚 Learning: 2025-10-16T07:19:52.418Z
Learnt from: grivera64
Repo: gofiber/fiber PR: 3807
File: adapter_test.go:118-144
Timestamp: 2025-10-16T07:19:52.418Z
Learning: In the Fiber codebase, the linter does not allow `require` assertions from within HTTP handlers (including net/http-style handlers). Use `t.Fatalf`, `t.Errorf`, or similar `testing.T` methods for error handling inside handler functions instead.

Applied to files:

  • client/client_test.go
  • client/helper_test.go
  • middleware/proxy/proxy_test.go
  • middleware/idempotency/idempotency_test.go
📚 Learning: 2025-10-16T07:15:26.529Z
Learnt from: grivera64
Repo: gofiber/fiber PR: 3807
File: adapter_test.go:118-144
Timestamp: 2025-10-16T07:15:26.529Z
Learning: In Fiber v3, net/http handlers (http.Handler, http.HandlerFunc, or raw func(http.ResponseWriter, *http.Request)) can be passed directly to routing methods like app.Get(), app.Post(), etc. The framework automatically detects and wraps them internally via toFiberHandler/collectHandlers. The github.com/gofiber/fiber/v3/middleware/adaptor package is legacy and should not be suggested for tests or code using native net/http handler support.

Applied to files:

  • client/helper_test.go
  • middleware/proxy/proxy_test.go
  • middleware/idempotency/idempotency_test.go
📚 Learning: 2024-09-25T16:18:34.719Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/session/config.go:122-122
Timestamp: 2024-09-25T16:18:34.719Z
Learning: In `DefaultErrorHandler(c *fiber.Ctx, err error)`, since `c` is a pointer to an interface, we need to dereference `*c` when calling interface methods like `SendStatus`.

Applied to files:

  • middleware/proxy/proxy_test.go
  • middleware/idempotency/idempotency_test.go
📚 Learning: 2024-10-08T19:06:06.583Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/csrf/csrf_test.go:188-193
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In the Fiber framework tests, using `ctx.Response.Header.Cookie` may not be suitable for parsing cookies from the response header, as it requires a `*Cookie` and fills it rather than returning a string value; thus, manual parsing of the `Set-Cookie` header may be necessary.

Applied to files:

  • middleware/proxy/proxy_test.go
📚 Learning: 2024-09-25T17:05:06.991Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/session/middleware_test.go:190-191
Timestamp: 2024-09-25T17:05:06.991Z
Learning: When testing session `IdleTimeout` expiration, it's acceptable to use `time.Sleep` to simulate the passage of time in tests.

Applied to files:

  • middleware/proxy/proxy_test.go
📚 Learning: 2024-09-25T17:09:03.756Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/session/middleware_test.go:400-407
Timestamp: 2024-09-25T17:09:03.756Z
Learning: In the `Test_Session_Next` function in `middleware/session/middleware_test.go`, the variable `doNext` is properly synchronized with the `muNext` mutex for both read and write access.

Applied to files:

  • middleware/idempotency/idempotency_test.go
🧬 Code graph analysis (5)
ctx_interface_gen.go (2)
router.go (1)
  • Route (43-64)
app.go (1)
  • Map (43-43)
req.go (1)
constants.go (6)
  • StrGzip (299-299)
  • StrBr (302-302)
  • StrBrotli (304-304)
  • StrDeflate (303-303)
  • StrZstd (305-305)
  • HeaderXForwardedHost (220-220)
client/client_test.go (1)
listen.go (3)
  • App (287-324)
  • App (342-360)
  • ListenConfig (42-125)
middleware/proxy/proxy_test.go (2)
app.go (1)
  • TestConfig (1093-1104)
constants.go (2)
  • NetworkTCP4 (292-292)
  • MethodGet (5-5)
middleware/idempotency/idempotency_test.go (1)
app.go (1)
  • TestConfig (1093-1104)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: lint
  • GitHub Check: repeated
  • GitHub Check: unit (1.25.x, macos-latest)
  • GitHub Check: unit (1.25.x, macos-13)
  • GitHub Check: unit (1.25.x, windows-latest)
  • GitHub Check: Compare
🔇 Additional comments (15)
middleware/idempotency/idempotency_test.go (2)

84-84: LGTM: http.NoBody migration is correct.

Replacing nil with http.NoBody across all test request creation is the proper way to represent an empty request body and aligns with the gocritic httpNoBody linting check. Since none of these tests require actual request bodies, the change is semantically equivalent while being more explicit.

Also applies to: 250-250, 254-254, 268-268, 283-283, 298-298, 324-324, 331-331, 348-348, 368-368, 382-382, 396-396, 411-411


226-236: Helper function changes maintain clarity.

The addition of named returns and the variable rename from body to payload avoids shadowing the return parameter while keeping the function's behavior unchanged. The nolint comment appropriately explains the design choice.

middleware/cache/heap.go (1)

84-96: LGTM: Named returns added to satisfy gocritic.

The addition of named return values to these three methods addresses gocritic's unnamedResult check as described in the PR objectives. The approach is consistent across all three methods, and the nolint directives appropriately document the conflict with the nonamedreturns check. Since the function bodies still use explicit returns rather than relying on implicit named returns, the behavior remains unchanged.

client/client_test.go (2)

29-36: LGTM! Named returns properly implemented for gocritic compliance.

The function signature correctly uses named returns with an appropriate nolint comment explaining the requirement. The initialization of app via assignment (rather than declaration) is the correct approach when using named return values.


40-50: Good practice: explicit parameter instead of closure capture.

While not strictly required for the named returns refactor, passing app as an explicit parameter to the goroutine (rather than capturing it from the closure) makes the data flow more explicit and is generally better practice for concurrent code.

client/helper_test.go (1)

73-88: LGTM! Clean refactor to named returns.

The function has been cleanly refactored to use named returns for gocritic compliance. The explicit variable definitions for dial and start with their function types make the code very readable, and the explicit return statement is good practice even with named returns.

internal/tlstest/tls.go (3)

20-20: LGTM: Named returns improve clarity for TLS config pair.

The named return parameters clearly distinguish the server and client TLS configurations, which is valuable given the function returns two configs of the same type. The nolint directive appropriately allows this to satisfy gocritic's unnamedResult preference while suppressing conflicting linters.


119-122: LGTM: Correct assignment syntax for named return.

The change from := to = is required because serverTLSConf is now a named return parameter. The assignment correctly sets the server TLS configuration that will be returned.


128-131: LGTM: Correct assignment syntax for named return.

The change from := to = is required because clientTLSConf is now a named return parameter. The assignment correctly sets the client TLS configuration that will be returned.

middleware/proxy/proxy_test.go (5)

7-7: LGTM! Import added for http.NoBody.

The net/http import is required for the http.NoBody constant used throughout the test file.


33-47: LGTM! Named returns implemented correctly.

The helper function now uses named returns with appropriate nolint documentation. The implementation correctly assigns to the named return variables and maintains existing behavior.


49-52: LGTM! Wrapper function with named returns.

The IPv4 wrapper correctly delegates to createProxyTestServer with the appropriate network constant.


54-57: LGTM! Wrapper function with named returns.

The IPv6 wrapper correctly delegates to createProxyTestServer with the appropriate network constant.


126-938: LGTM! Systematic replacement of nil with http.NoBody.

All test request constructions now correctly use http.NoBody instead of nil for empty request bodies. This addresses the gocritic httpNoBody check and aligns with Go best practices for test requests. The changes are consistent across all 33+ test cases and maintain existing behavior.

req.go (1)

84-127: Named returns keep decode accounting clear.

The switch to named results and the per-iteration decodeErr makes the decoding loop easier to follow without altering the existing fallbacks. Nice cleanup.

@ReneWerner87
Copy link
Member Author

Finally, lint is successful

Copy link
Member

@gaby gaby left a comment

Choose a reason for hiding this comment

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

LGTM, great find

@gaby
Copy link
Member

gaby commented Nov 11, 2025

@ReneWerner87 Can we update this branch to see if release-drafter kicks? It should had tagged this PR as bug

@ReneWerner87
Copy link
Member Author

Sure

@gaby gaby changed the title Fix gocritic httpNoBody and hugeParam issues 🐛 bug: fix gocritic httpNoBody and hugeParam issues Nov 11, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ce7a74f and b445ffe.

📒 Files selected for processing (4)
  • docs/middleware/limiter.md (2 hunks)
  • docs/middleware/logger.md (3 hunks)
  • docs/middleware/proxy.md (2 hunks)
  • docs/whats_new.md (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
docs/**

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Review and update the contents of the docs folder if necessary when modifying code

Files:

  • docs/middleware/proxy.md
  • docs/whats_new.md
  • docs/middleware/limiter.md
  • docs/middleware/logger.md
🧠 Learnings (5)
📓 Common learnings
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 2864
File: ctx_test.go:4816-4816
Timestamp: 2024-10-08T19:06:06.583Z
Learning: The `ParamsInt` function's behavior, including handling empty string parameters, will be addressed in future PRs as per ReneWerner87's guidance.
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 2864
File: ctx_test.go:4816-4816
Timestamp: 2024-07-26T21:00:12.902Z
Learning: The `ParamsInt` function's behavior, including handling empty string parameters, will be addressed in future PRs as per ReneWerner87's guidance.
📚 Learning: 2025-10-16T07:15:26.529Z
Learnt from: grivera64
Repo: gofiber/fiber PR: 3807
File: adapter_test.go:118-144
Timestamp: 2025-10-16T07:15:26.529Z
Learning: In Fiber v3, net/http handlers (http.Handler, http.HandlerFunc, or raw func(http.ResponseWriter, *http.Request)) can be passed directly to routing methods like app.Get(), app.Post(), etc. The framework automatically detects and wraps them internally via toFiberHandler/collectHandlers. The github.com/gofiber/fiber/v3/middleware/adaptor package is legacy and should not be suggested for tests or code using native net/http handler support.

Applied to files:

  • docs/middleware/proxy.md
  • docs/whats_new.md
  • docs/middleware/limiter.md
📚 Learning: 2024-11-15T07:56:21.623Z
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.

Applied to files:

  • docs/whats_new.md
📚 Learning: 2024-10-08T19:06:06.583Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/csrf/csrf_test.go:164-165
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In the `Test_CSRF_WithSession_Middleware` function, calling `session.NewWithStore()` without arguments is acceptable, as the default configuration is sufficient.

Applied to files:

  • docs/whats_new.md
📚 Learning: 2024-09-25T16:17:00.969Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/session/config.go:16-26
Timestamp: 2024-09-25T16:17:00.969Z
Learning: In the session middleware `Config` struct, `Store` is backed by `fiber.Storage`; they are different entities serving distinct purposes in session management.

Applied to files:

  • docs/middleware/limiter.md
🪛 LanguageTool
docs/middleware/logger.md

[style] ~175-~175: In American English, abbreviations like “etc.” require a period.
Context: ...ogging libraries (Zerolog, Zap, Logrus, etc). Defaults to Fiber's default logger if...

(ETC_PERIOD)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Compare
  • GitHub Check: unit (1.25.x, macos-latest)
  • GitHub Check: unit (1.25.x, windows-latest)
  • GitHub Check: repeated
  • GitHub Check: lint
  • GitHub Check: update_release_draft
🔇 Additional comments (6)
docs/middleware/proxy.md (1)

13-13: Documentation properly reflects Balancer variadic signature change.

The signature update to variadic config is clearly documented and all examples show appropriate usage patterns.

docs/middleware/logger.md (1)

103-117: Documentation correctly reflects LoggerFunc pointer-to-Config signature change.

The config parameter is now properly documented as a pointer type, and examples for predefined formats are clear and consistent.

docs/middleware/limiter.md (1)

23-26: Handler interface properly documented with pointer-to-Config signature.

The new interface signature is clearly presented and the LimiterMiddleware field explanation properly communicates the pointer-based config pattern.

docs/whats_new.md (3)

1285-1286: LoggerFunc signature change properly documented with migration guidance.

The documentation clearly explains the shift to pointer-based config in custom logger implementations and provides clear examples of the updated signature.


1448-1449: Limiter Handler interface change well-explained for custom implementations.

The documentation accurately conveys that custom algorithms must now implement the updated interface with pointer-to-Config parameter, supporting migration from v2 to v3.


1466-1467: Proxy.Balancer variadic config change consistently documented.

Both the feature overview (lines 1466-1467) and migration guide (line 2487) properly document the move to optional variadic configuration, providing clear guidance for users upgrading from v2.

Also applies to: 2487-2487

@ReneWerner87 ReneWerner87 merged commit 80f560b into main Nov 12, 2025
15 of 16 checks passed
@ReneWerner87 ReneWerner87 deleted the codex/2025-11-10-11-30-24 branch November 12, 2025 20:02
@github-project-automation github-project-automation bot moved this to Done in v3 Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants