Conversation
|
CodeAnt AI is reviewing your PR. Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| export async function parseOBSMarkdown(file: File): Promise<OBSStory> { | ||
| const content = await file.text(); | ||
|
|
||
| const story_no = parseInt(file.name.replace(/\.md$/i, ""), 10); |
There was a problem hiding this comment.
Suggestion: parseInt is used directly on the filename stem without validating that the entire stem is numeric. Filenames like abc.md produce NaN, and filenames like 1-extra.md are silently coerced to 1, which can lead to invalid or incorrect story_no values being uploaded and break sorting/dedup behavior. Enforce a strict numeric filename format and reject invalid names before returning the story object. [logic error]
Severity Level: Major ⚠️
- ❌ Malformed filenames create stories with NaN story numbers.
- ⚠️ Story deduplication by story_no fails for NaN.
- ⚠️ Sorting stories by story_no becomes inconsistent with NaN.Steps of Reproduction ✅
1. In `OBSViewDialog` (`frontend/src/components/OBSViewDialog.tsx:229-241`),
`handleAddStories` accepts any `.md` files without validating that filenames are numeric.
2. `handleAddStories` calls `parseOBSMarkdownFiles`
(`frontend/src/utils/obsParser.ts:84-89`), which in turn calls `parseOBSMarkdown` for each
file.
3. In `parseOBSMarkdown` (`frontend/src/utils/obsParser.ts:64-79`), `story_no` is derived
via `parseInt(file.name.replace(/\.md$/i, ""), 10)` at line 66; passing a file named
`abc.md` yields `parseInt("abc", 10) === NaN`, and a file named `1-extra.md` yields
`parseInt("1-extra", 10) === 1`.
4. The resulting `OBSStory` objects with `story_no` set to `NaN` or coerced values are
used in `handleAddStories` to build `existing` and `toUpload` sets
(`OBSViewDialog.tsx:242-247`) and later for display and deletion, meaning malformed
filenames lead to invalid IDs, broken deduplication (`Set.has(NaN)` is always false), and
inconsistent sorting by `story_no`.Fix in Cursor | Fix in VSCode Claude
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** frontend/src/utils/obsParser.ts
**Line:** 66:66
**Comment:**
*Logic Error: `parseInt` is used directly on the filename stem without validating that the entire stem is numeric. Filenames like `abc.md` produce `NaN`, and filenames like `1-extra.md` are silently coerced to `1`, which can lead to invalid or incorrect `story_no` values being uploaded and break sorting/dedup behavior. Enforce a strict numeric filename format and reject invalid names before returning the story object.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix|
CodeAnt AI finished reviewing your PR. |
CodeAnt-AI Description
Handle OBS story numbers from the file name instead of the heading
What Changed
.mdfile name, while the heading is used for the story titleImpact
✅ Fewer blocked OBS edits✅ Easier markdown imports✅ Better support for non-English story headings💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.