Uh oh!
There was an error while loading. Please reload this page.
feat(init): validate config at entry — close #15, #18 - #31
Conversation
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR adds synchronous pre-flight validation to the ReCost Node SDK's ChangesConfiguration validation for cloud mode
Sequence DiagramsequenceDiagram
participant Caller
participant init
participant validateConfig
participant Transport
Caller->>init: init(config)
init->>init: check enabled gate
alt enabled is false
init-->>Caller: return disabled handle
else enabled is true
init->>validateConfig: validateConfig(config)
alt invalid config
validateConfig-->>Caller: throw Error
else valid config
validateConfig-->>init: return
init->>Transport: install interceptor
init->>init: start flush timer
init-->>Caller: return handle
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Summary
validateConfig(config)(src/core/validate-config.ts) called at the top ofinit(), before any side effects (interceptor patch, timer, transport).projectId, produces 404 URLs #15 (Critical): cloud mode no longer accepts an emptyprojectIdand produces/projects//telemetry404s —init()throws with a dashboard link instead.apiKey(non-rc-prefix, literal string"undefined", empty) is rejected at init with an actionable message; secret is redacted to an 8-char preview in the error.apiKey) remains validation-free.Behavior change
Previously-broken cloud configs (silent 404s or 401s forever) now throw at
init(). No real telemetry is lost — these users were never shipping data. Consider a 0.2.0 bump and a "Breaking" callout if you want to signal the new throwing contract explicitly.Test plan
validateConfig(tests/validate-config.test.ts)tests/init.test.tspinning that throws gate the interceptor install (regression contract:isInstalled() === falseafter throw)npm run lintcleannpm run buildclean (ESM + CJS + DTS)node -e "require('./dist/cjs/index.cjs').init({apiKey:'bad'})"throws with the expected messageCloses#15
Closes#18
Summary by CodeRabbit
New Features
Documentation
Tests