Skip to content

docs: fix SessionConfig struct literal syntax in handler examples#577

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
docs/fix-session-config-struct-literals-7d5561ab3a7f3c06
Draft

docs: fix SessionConfig struct literal syntax in handler examples#577
github-actions[bot] wants to merge 1 commit into
mainfrom
docs/fix-session-config-struct-literals-7d5561ab3a7f3c06

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

Several documentation code examples used invalid Go syntax: they initialized promoted fields from the embedded SessionConfig struct directly in handler struct literals, which the Go compiler rejects. The Go specification requires that struct literal keys be field names declared at the top level of the struct type — promoted fields from an embedded type must be initialized via the embedded type name.

Example of broken syntax (from docs):

h := &handler.AuthHandler{
    Users:             userStore,
    JWT:               jwtMgr,
    CookieName:        "session",   // ❌ promoted field — compiler error
    SecureCookies:     true,        // ❌ promoted field — compiler error
    Sessions:          sessionStore, // ❌ promoted field — compiler error
    RefreshTokenTTL:   ...,         // ❌ promoted field — compiler error
    RefreshCookieName: "refresh",   // ❌ promoted field — compiler error
}

Corrected syntax (consistent with README):

h := &handler.AuthHandler{
    Users: userStore,
    JWT:   jwtMgr,
    SessionConfig: handler.SessionConfig{
        CookieName:        "session",
        SecureCookies:     true,
        Sessions:          sessionStore,
        RefreshTokenTTL:   handler.DefaultRefreshTokenTTL,
        RefreshCookieName: "refresh",
    },
}

Files changed

File Issue
docs/handler/auth.md AuthHandler struct literal used promoted SessionConfig fields
docs/handler/magic-links.md MagicLinkHandler struct literal used promoted SessionConfig fields
docs/handler/passkeys.md PasskeyHandler struct literal used promoted SessionConfig fields
docs/handler/oauth2.md OAuth2Handler struct literal used promoted SessionConfig fields
docs/index.md Quick-start AuthHandler example used promoted SessionConfig fields
docs/tutorial.md AuthHandler example + maintenance.StartCleanup missing nil logger argument

The docs/tutorial.md fix also corrects a second issue: maintenance.StartCleanup takes (ctx, logger, interval, cleaners...) but the tutorial called (ctx, interval, cleaners...), omitting the required *slog.Logger parameter. The corrected call passes nil (which uses slog.Default() at each log site).

All fixes match the correct syntax already present in README.md.

Generated by Update Docs · 912.3 AIC · ⌖ 13.6 AIC · ⊞ 34.4K ·

Add this agentic workflows to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/update-docs.md@96b9d4c39aa22359c0b38265927eadb31dcf4e2a

Handler types (AuthHandler, MagicLinkHandler, PasskeyHandler,
OAuth2Handler) embed SessionConfig rather than declaring its fields
directly. Go does not allow promoted fields as keys in composite
struct literals; the embedded type name must be used instead.

Update all affected code examples across:
- docs/handler/auth.md
- docs/handler/magic-links.md
- docs/handler/passkeys.md
- docs/handler/oauth2.md
- docs/index.md
- docs/tutorial.md

Also fix docs/tutorial.md: maintenance.StartCleanup now takes a
*slog.Logger as its second argument; pass nil to use slog.Default().
The previous example omitted this parameter entirely, making the
code non-compilable.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added automation documentation Improvements or additions to documentation labels Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants