fix #1161#1170
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
WalkthroughThe training handler now enforces stricter type validation for DAG node identifiers. The change adds Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
packages/hydrooj/src/handler/training.tsESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. 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 |
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/hydrooj/src/handler/training.ts (1)
2-2: Tighten_idvalidation: lodashisNumberacceptsNaN(andInfinity)The
_id: 0fix is correct, but_.isNumber(NaN)returnstrue, so the currentassert(isNumber(node._id), ...)would allow_id: NaN, which then staysNaNafter_id: +node._id.Suggested change
-assert(isNumber(node._id), '_id should be a number'); +assert(isNumber(node._id) && !Number.isNaN(node._id), '_id should be a number');🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/hydrooj/src/handler/training.ts` at line 2, The current check assert(isNumber(node._id), ...) allows NaN/Infinity; tighten validation by asserting Number.isFinite(+node._id) (or Number.isFinite(node._id) if you only accept numeric types) before converting — i.e. replace the assert(isNumber(node._id), ...) check with an assertion that uses Number.isFinite on the numeric value and then keep the existing conversion _id: +node._id so NaN/Infinity are rejected.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/hydrooj/src/handler/training.ts`:
- Line 2: The current check assert(isNumber(node._id), ...) allows NaN/Infinity;
tighten validation by asserting Number.isFinite(+node._id) (or
Number.isFinite(node._id) if you only accept numeric types) before converting —
i.e. replace the assert(isNumber(node._id), ...) check with an assertion that
uses Number.isFinite on the numeric value and then keep the existing conversion
_id: +node._id so NaN/Infinity are rejected.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a297593f-18b8-41e5-b6c0-0cd2cb575e71
📒 Files selected for processing (1)
packages/hydrooj/src/handler/training.ts
Summary by CodeRabbit