Skip to content

Conversation

sedkis
Copy link
Contributor

@sedkis sedkis commented Sep 23, 2025

User description

Contributor checklist

  • Reviewed PR Code suggestions and updated accordingly
  • Tyklings: Labled the PR with the relevant releases
  • Tyklings: Added Jira DX PR ticket to the subject

New Contributors



PR Type

Documentation


Description

  • Add warning note about session timing

  • Clarify ctx.GetSession behavior in auth plugins


Diagram Walkthrough

flowchart LR
  Auth["Custom Authentication Middleware"] -- "sets Session" --> PostAuthMW["Post-auth Middleware Chain"]
  PreAuthMW["Pre-auth/custom auth plugins"] -- "ctx.GetSession => empty" --> Auth
  PostAuthMW -- "ctx.GetSession => valid" --> Handlers["Downstream Handlers"]
Loading

File Walkthrough

Relevant files
Documentation
golang.md
Add session timing warning for Go plugins                               

tyk-docs/content/api-management/plugins/golang.md

  • Add warning note shortcode block.
  • Explain session set during authentication layer.
  • State ctx.GetSession returns empty in custom auth plugin.
+6/-0     

Copy link
Contributor

⚠️ Deploy preview for PR #6959 did not become live after 3 attempts.
Please check Netlify or try manually: Preview URL

Copy link
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Grammar/Clarity

Minor grammatical issues: use "A Session is set" or "The session is set" consistently, "middleware chain after the authentication middleware layer" could be simplified, and "returns an empty object" might be clearer as "returns an empty session".

{{< note warning >}}
**Note**  

The Session is set during the (custom) Authentication layer - meaning it won't be set until the middleware chain after the authentication middleware layer.    Trying to use `ctx.GetSession` in a custom auth plugin would always return an empty object.
{{< /note >}}

The invocation of `ctx.GetSession(r)` returns an SessionState object.
Terminology Consistency

Use consistent casing for "Session/session" and "Authentication/auth" throughout the note to match house style; also consider "ctx.GetSession(r)" for consistency with the following paragraph.

{{< note warning >}}
**Note**  

The Session is set during the (custom) Authentication layer - meaning it won't be set until the middleware chain after the authentication middleware layer.    Trying to use `ctx.GetSession` in a custom auth plugin would always return an empty object.
{{< /note >}}

The invocation of `ctx.GetSession(r)` returns an SessionState object.

Copy link
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Correct session behavior wording

Clarify that ctx.GetSession(r) returns nil/no session rather than an "empty object"
to avoid misleading Go developers. Also remove duplicate spaces and fix the article
to "a SessionState object" for accuracy and readability.

tyk-docs/content/api-management/plugins/golang.md [521-526]

 {{< note warning >}}
-**Note**  
+Note:
 
-The Session is set during the (custom) Authentication layer - meaning it won't be set until the middleware chain after the authentication middleware layer.    Trying to use `ctx.GetSession` in a custom auth plugin would always return an empty object.
+The session is set during the (custom) authentication layer—meaning it won't be available until the middleware chain after the authentication middleware layer. Trying to use `ctx.GetSession(r)` in a custom auth plugin will return no session (nil).
 {{< /note >}}
Suggestion importance[1-10]: 6

__

Why: The clarification from “empty object” to “no session (nil)” improves technical accuracy for Go readers and cleans minor wording issues. It’s a helpful documentation fix with moderate impact and correctly targets the new hunk lines.

Low

Copy link

netlify bot commented Sep 23, 2025

PS. Add to the end of url /docs/nightly

Name Link
🔨 Latest commit c041f21
🔍 Latest deploy log https://app.netlify.com/projects/tyk-docs/deploys/68e518802dc44700087bba15
😎 Deploy Preview https://deploy-preview-6959--tyk-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@sharadregoti sharadregoti changed the title Update golang.md Add a Note on the availability of ctx.GetSession(r) in the middleware chain Oct 7, 2025
@sharadregoti sharadregoti merged commit 01bbb8a into master Oct 7, 2025
13 checks passed
@sharadregoti sharadregoti deleted the sedkis-patch-1 branch October 7, 2025 13:54
@sharadregoti
Copy link
Contributor

/release to release-5.8

@sharadregoti
Copy link
Contributor

/release to release-5.9

Copy link
Contributor

tykbot bot commented Oct 7, 2025

Working on it! Note that it can take a few minutes.

1 similar comment
Copy link
Contributor

tykbot bot commented Oct 7, 2025

Working on it! Note that it can take a few minutes.

Copy link
Contributor

tykbot bot commented Oct 7, 2025

@sharadregoti Created merge PRs

Copy link
Contributor

tykbot bot commented Oct 7, 2025

@sharadregoti Created merge PRs

buger added a commit that referenced this pull request Oct 7, 2025
…sion(r)` in the middleware chain (#6959)

Add a Note on the availability of `ctx.GetSession(r)` in the middleware chain (#6959)
buger added a commit that referenced this pull request Oct 7, 2025
…sion(r)` in the middleware chain (#6959)

Add a Note on the availability of `ctx.GetSession(r)` in the middleware chain (#6959)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants