Repository navigation
feat: name misconfigured environment variables on startup - #1176
bsaurusrex wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughEnvironment loading now identifies unknown and invalid variables and avoids exposing decoder values in errors. The command passes unknown names to bootstrap setup for warnings. Empty App URLs and invalid URL formats receive updated error messages. ChangesEnvironment configuration diagnostics
Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant RootCommand
participant EnvLoader
participant runCmd
participant BootstrapApp
RootCommand->>EnvLoader: Load environment configuration
EnvLoader-->>RootCommand: Return ignored variable names
RootCommand->>runCmd: Pass ignored variable names
runCmd->>BootstrapApp: Set ignored variables
BootstrapApp->>BootstrapApp: Log warning and validate App URL
Merge Risk: ⚪ Minimal · up to The startup diagnostics are mergeable after normal checks; no material issue remains identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Most startup failures reported after the v5 configuration change were renamed or misspelled environment variables, and the errors did not name them: - an unset app url failed with "failed to parse app url: invalid url". It now says the app url is not set and how to set it, and points at APP_URL / TINYAUTH_APP_URL when one of those (v4 style) is set. - TINYAUTH_ variables that match no configuration section were silently ignored. They are now logged as a warning once the logger is set up. Kubernetes service link variables (TINYAUTH_SERVICE_HOST, TINYAUTH_PORT, ...) are skipped. - a variable inside a known section that fails to decode only reported the internal node name (e.g. "node: databasepath"). The error now lists the variables that fail to decode on their own, and no longer propagates the decoder error, which could echo the offending value (a secret pasted into the wrong variable) into the logs. Also fixes the "https(s)" typo in the app url format error. Refs tinyauthapp#685 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8455e04 to
9ac8416
Compare
|
@bsaurusrex Thanks for the contribution! I'm not sure this additional check is necessary, since configuration parsing already fails by design when an invalid recognized environment variable is provided. I think the existing behavior is sufficient without introducing additional warnings or validation. |
Refs #685 (one of four small, independent PRs from that thread; they merge cleanly in any order)
Problem
Most startup reports in #685 were renamed or misspelled environment variables after the v5 config change, and the errors did not name them:
failed to parse app url: invalid url;TINYAUTH_*variables that match no config section were dropped silently, e.g.TINYAUTH_SECURECOOKIEinstead ofTINYAUTH_AUTH_SECURECOOKIE, so a setting looks enabled but isn't;node: databasepath).Change
TINYAUTH_APPURL,--appurlorappUrlin the config file). It notes that environment variables are ignored once a config file or CLI flags are used, and points atAPP_URL/TINYAUTH_APP_URLif one of those v4-style names is set.TINYAUTH_*variables are logged as one warning through the app logger after startup. Kubernetes service-link variables (TINYAUTH_SERVICE_HOST,TINYAUTH_PORT_...) are skipped.check TINYAUTH_X, TINYAUTH_Y).https(s)typo in the app URL format error.No config is changed or mutated; this is diagnostics only.
Testing
make vet,make testandgo test -race ./...pass.loader_env_test.gocovers unknown and invalid detection and the Kubernetes exclusions.APP_URL,TINYAUTH_APP_URL, misspelled roots, and an invalid value inside a known section. Each one now names the variable.AI disclosure (per AI_POLICY.md): the code, tests and this description were written with Claude Code (Claude Opus 5.5), and the commit carries a
Co-Authored-Bytrailer. I reviewed the change myself and tested it as described below.🤖 Generated with Claude Code
Summary by CodeRabbit