fix(creds): WGER sentinel instead of unusable random token - #874
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe changes update the WGER API token generation workflow from auto-generated tokens with a Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
pmoves/tools/brand_defaults.py (1)
137-141: Teach the remaining WGER consumers about this sentinel.
pmoves/scripts/integration-auth-setup.sh:145-160andpmoves/integrations/health-wger/n8n/flows/health_wger_sync.json:28-35still treat any non-emptyWGER_API_TOKENas usable, so freshly seeded envs will continue sendingToken GENERATE_FROM_WGER_UIand only surface generic auth failures. Now that this sentinel is the canonical default, it would be worth updating those paths in the same change so operators get consistent guidance everywhere.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pmoves/tools/brand_defaults.py` around lines 137 - 141, The seeded default WGER_API_TOKEN value "GENERATE_FROM_WGER_UI" is a sentinel and must be treated as non-usable; update the integration-auth-setup script and the health_wger_sync n8n flow so they check for WGER_API_TOKEN == "GENERATE_FROM_WGER_UI" (not just non-empty) and behave like a missing token: do not export or attempt to use it, surface a clear message instructing operators to create a token from the WGER admin UI and paste it into WGER_API_TOKEN, and in the n8n flow short-circuit auth steps when the value equals the sentinel to return a helpful error/notification instead of attempting requests with "Token GENERATE_FROM_WGER_UI".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@pmoves/tools/brand_defaults.py`:
- Around line 207-211: The code currently calls mkdir() and write_text() before
the try that wraps upsert_env, so filesystem errors escape; move the
mkdir()/write_text() calls into the same try block that calls upsert_env (or
wrap the entire sequence that prepares and writes the env file — the mkdir(),
write_text(), and upsert_env calls involving variables env_path, env_gen_path,
and DEFAULTS) and keep the existing except OSError as e: print(...) and return 1
so any permission/disk failures are handled consistently.
---
Nitpick comments:
In `@pmoves/tools/brand_defaults.py`:
- Around line 137-141: The seeded default WGER_API_TOKEN value
"GENERATE_FROM_WGER_UI" is a sentinel and must be treated as non-usable; update
the integration-auth-setup script and the health_wger_sync n8n flow so they
check for WGER_API_TOKEN == "GENERATE_FROM_WGER_UI" (not just non-empty) and
behave like a missing token: do not export or attempt to use it, surface a clear
message instructing operators to create a token from the WGER admin UI and paste
it into WGER_API_TOKEN, and in the n8n flow short-circuit auth steps when the
value equals the sentinel to return a helpful error/notification instead of
attempting requests with "Token GENERATE_FROM_WGER_UI".
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4f424381-7ddc-4e87-9a45-3648533ae689
📒 Files selected for processing (2)
pmoves/docs/operations/SEEDED_BRANDED_DEFAULTS.mdpmoves/tools/brand_defaults.py
Django REST Framework tokens must be created via the admin UI — random tokens are rejected. Replace auto-generated pm_wger_ token with GENERATE_FROM_WGER_UI sentinel. Add sentinel to PLACEHOLDER_VALUES so future runs treat it as needing replacement. Wrap main() env file I/O in try/except OSError for graceful failure. Addresses CodeRabbit findings #2, #6 from PR #864. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace auto-generation claim with step-by-step Django admin instructions for creating the WGER API token manually. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
12dab3d to
cd98699
Compare
Summary
GENERATE_FROM_WGER_UIsentinel (Django REST Framework rejects random tokens)PLACEHOLDER_VALUESso future runs don't skip itmain()for env file write failuresAddresses CodeRabbit findings #2, #6 from PR #864.
Test plan
python -m py_compile pmoves/tools/brand_defaults.pyupsert_env()producesWGER_API_TOKEN=GENERATE_FROM_WGER_UI🤖 Generated with Claude Code