fix(standalone-api): /status 返回真实包版本(去掉硬编码常量) - #367
Conversation
The endpoint returned a module-local literal that release bumps never touched, so a running 0.8.13 answered /status with 0.7.12 — third-party integrations reading it got a stale version. Reuse PACKAGE_VERSION from version-check.js (the same source the host-side status route already reads) and drop the duplicate constant. The regression lock moves from the literal to PACKAGE_VERSION: pinning the string is what let the drift ship with a green CI.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (4)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughStandalone API 的 ChangesStandalone API 状态版本号
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~8 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The standalone status version now follows package metadata in both source and distributable code. No actionable merge-blocking risk remains. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
问题
GET /status返回的版本号来自src/api-standalone.js内的字面量常量,而它不会随发版 bump(注释自己写着「package.json 在发布时会 bump」)。实测:一个运行 0.8.13 的实例对外报0.7.12——第三方集成拿这个字段判版本,读到的是假数据。修法
复用既有的
PACKAGE_VERSION(src/version-check.js,运行时读package.json)——宿主侧的/api/dsh-mneme/status早就在用它,standalone 面反而是唯一的第二真源。删掉重复常量,/status与宿主状态页从此同源。回归锁
test/standalone-api.test.js原本断言body.version === "0.7.12"——锁字面量正是漏 bump 没被 CI 拦下的原因:测试只证明「常量和它自己一致」。改为断言等于PACKAGE_VERSION,版本漂移从此必红。变异检验:把实现改回字面量,该用例变红(1 fail);还原后 21/21 绿。全量
npm test1537 通过 / 0 失败(与双 README 徽章计数一致,无需刷徽章)。范围
一行实现 + 一条断言改写,不触及其他端点与配置面。附带把文件头注释里的过时版本号
(v0.7.12)去掉。Summary by CodeRabbit
/status端点现在返回与当前软件包版本一致的版本号,不再显示过时的固定版本。