Skip to content

Handle OBS story number from md file #489

Merged
RevantCI merged 1 commit into
devfrom
obs-fix
May 14, 2026
Merged

Handle OBS story number from md file #489
RevantCI merged 1 commit into
devfrom
obs-fix

Conversation

@KetanKBaboo
Copy link
Copy Markdown
Contributor

@KetanKBaboo KetanKBaboo commented May 14, 2026

CodeAnt-AI Description

Handle OBS story numbers from the file name instead of the heading

What Changed

  • Markdown imports now take the story number from the .md file name, while the heading is used for the story title
  • Story edits no longer fail when the number in the heading does not match the saved story number
  • Story headings can now use numeric characters from other writing systems, not just plain digits

Impact

✅ 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:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

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:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

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.

@KetanKBaboo KetanKBaboo requested a review from RevantCI May 14, 2026 10:11
@KetanKBaboo KetanKBaboo self-assigned this May 14, 2026
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented May 14, 2026

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 ·
Reddit ·
LinkedIn

@vercel
Copy link
Copy Markdown

vercel Bot commented May 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
vachan-admin-v2 Ready Ready Preview, Comment May 14, 2026 10:11am

Request Review

@codeant-ai codeant-ai Bot added the size:XS This PR changes 0-9 lines, ignoring generated files label May 14, 2026
export async function parseOBSMarkdown(file: File): Promise<OBSStory> {
const content = await file.text();

const story_no = parseInt(file.name.replace(/\.md$/i, ""), 10);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown

codeant-ai Bot commented May 14, 2026

CodeAnt AI finished reviewing your PR.

@RevantCI RevantCI merged commit 440d9e5 into dev May 14, 2026
2 of 4 checks passed
@RevantCI RevantCI deleted the obs-fix branch May 14, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants