Skip to content

docs: note removal of context keys#3707

Merged
ReneWerner87 merged 2 commits intomainfrom
codex/2025-08-23-17-20-43
Aug 23, 2025
Merged

docs: note removal of context keys#3707
ReneWerner87 merged 2 commits intomainfrom
codex/2025-08-23-17-20-43

Conversation

@ReneWerner87
Copy link
Member

Summary

  • remove ContextKey mentions from BasicAuth and KeyAuth docs
  • add a single changelog note explaining that all middlewares dropped the ContextKey option

Testing

  • make audit (fails: EncodeMsg passes lock by value; session/data_msgp.go lock copy)
  • make generate
  • make betteralign (fails: package requires newer Go version go1.25 (application built with go1.24))
  • make modernize (fails: package requires newer Go version go1.25 (application built with go1.24))
  • make format
  • make test (fails: Test_App_BodyLimit_LargerThanDefault timeout)

https://chatgpt.com/codex/tasks/task_e_68a9f436ea1883268b1f69302fb4ca60

Copilot AI review requested due to automatic review settings August 23, 2025 17:20
@ReneWerner87 ReneWerner87 requested a review from a team as a code owner August 23, 2025 17:20
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 PR removes outdated documentation references to the ContextKey configuration option from middleware documentation and consolidates the explanation in the changelog. The changes clean up documentation by removing redundant ContextKey mentions from individual middleware sections and adding a single comprehensive note explaining that all middlewares have dropped this option.

  • Removes specific ContextKey removal notes from CSRF middleware documentation
  • Adds a general note in the migration section explaining the removal across all middlewares
  • Consolidates documentation to avoid repetition and improve clarity

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 23, 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.

Warning

Rate limit exceeded

@ReneWerner87 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 0 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between f939023 and bf7b1c8.

📒 Files selected for processing (1)
  • docs/whats_new.md (1 hunks)

Walkthrough

Documentation update to whats_new.md describing middleware API shifts: context-based data storage with FromContext helpers, removal of ContextKey and KeyLookup patterns, CSRF/Session renames and extractor adoption, BasicAuth and KeyAuth API adjustments, timeout.New signature change, and updates to testing config.

Changes

Cohort / File(s) Summary
Docs: What's New
docs/whats_new.md
Documented middleware context storage and new FromContext helpers; removal of ContextKey and KeyLookup; CSRF IdleTimeout rename and FromCookie removal; Session constructor/timeout/extractor changes; timeout.New signature update; BasicAuth and KeyAuth API adjustments; app.Test signature change; migration guidance added.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client
  participant Fiber as Fiber App
  participant MW as Middleware
  participant Ctx as Request Context
  participant Handler as Route Handler

  Client->>Fiber: HTTP Request
  Fiber->>MW: Invoke middleware chain
  rect rgba(200,230,255,0.3)
    note right of MW: Middleware extracts data (e.g., token, session, request ID)
    MW->>Ctx: Store unexported values
  end
  MW-->>Fiber: Next()
  Fiber->>Handler: Call handler
  rect rgba(220,255,220,0.3)
    Handler->>Ctx: requestid.FromContext / csrf.TokenFromContext / session.FromContext / keyauth.TokenFromContext
    Ctx-->>Handler: Return value(s)
  end
  Handler-->>Fiber: Response
  Fiber-->>Client: HTTP Response
Loading

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related issues

Possibly related PRs

Suggested labels

v3

Suggested reviewers

  • gaby
  • sixcolors
  • efectn

Poem

Hop hop! I stash the keys in context burrows deep,
No more stringy clover where old secrets sleep.
Tokens, IDs, sessions—FromContext I seek,
New trails through fields of Go, tidy and sleek.
With whiskers twitching, I bound to v3—
A faster warren for code and me! 🐇✨

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/2025-08-23-17-20-43

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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.

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 updates the project documentation to reflect changes in middleware configurations, specifically the removal of the ContextKey option across various middlewares. It aims to ensure the documentation accurately reflects the current API, guiding users on how to retrieve data from context using new helper functions instead of user-defined keys.

Highlights

  • Documentation Cleanup: Removed specific mentions of ContextKey removal from the CSRF middleware documentation, streamlining the whats_new.md file.
  • General ContextKey Removal Note: Added a new, general changelog entry in whats_new.md to inform users that all middlewares have dropped their ContextKey configuration option, emphasizing the use of dedicated helper functions for data retrieval.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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.

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 refactors the documentation to centralize information about the removal of the ContextKey option in middlewares. The changes correctly remove specific notes for CSRF and add a general note in the migration guide. This improves the clarity and conciseness of the documentation. I've suggested a small wording improvement to make the new general note even more direct and less redundant.

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)
docs/whats_new.md (2)

2003-2004: Tighten scope and add guidance for third-party middleware

“All middlewares” may be interpreted as including community/contrib packages that haven’t migrated. Suggest narrowing the scope to Fiber-maintained middleware and adding a brief note for external packages.

Apply this diff:

-All middlewares have also dropped their `ContextKey` configuration option. Values are no longer stored under user-defined keys; instead, retrieve them with the helper functions described below.
+All Fiber-maintained middlewares have dropped their `ContextKey` configuration option. Values are no longer stored under user-defined keys; retrieve them via the helper functions listed below. For contrib or third-party middleware, consult their documentation to confirm whether `ContextKey` is still supported or which helper to use.

2003-2004: Optional: add one-line migration nudge to make next step explicit

A short “do this now” sentence helps readers translate the note into action.

Proposed follow-up sentence (append after the paragraph):

Migration: remove any `ContextKey` fields from your middleware configs and replace `c.Locals("<key>")` reads with the corresponding `Xxx.FromContext(c)` helper.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between bd7fd56 and f939023.

📒 Files selected for processing (1)
  • docs/whats_new.md (1 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/whats_new.md
🧠 Learnings (4)
📓 Common learnings
Learnt from: gaby
PR: gofiber/fiber#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.
📚 Learning: 2024-11-08T04:10:42.990Z
Learnt from: gaby
PR: gofiber/fiber#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:

  • docs/whats_new.md
📚 Learning: 2024-11-10T23:44:13.704Z
Learnt from: gaby
PR: gofiber/fiber#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:

  • docs/whats_new.md
📚 Learning: 2024-10-08T19:06:06.583Z
Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/csrf/session_manager.go:30-43
Timestamp: 2024-10-08T19:06:06.583Z
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:

  • docs/whats_new.md
🔇 Additional comments (2)
docs/whats_new.md (2)

2003-2004: LGTM: clear migration callout for ContextKey removal

This succinctly communicates the cross-middleware breaking change and fits well in the migration section.


2003-2004: ContextKey References Cleaned Up

A repo-wide search for remaining ContextKey mentions confirms that only the intended reference in the migration note remains.

• docs/whats_new.md:2003 – the single, expected mention in the “What’s New” guide
• No other occurrences in docs/ or middleware/**/*.md

All other ContextKey usages have been removed.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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.

2 participants