fix: import list-marker stripping eats leading numbers in resume content#354
Open
Mubashirrrr wants to merge 1 commit into
Open
Conversation
toStringArray() turns a multi-line string into list items and strips a
leading list marker from each line. The strip regex /^[-*•\d.)\s]+/ put
\d, "." and ")" in the same greedy character class, so it removed any run
of leading digits/dots/parens, not just an actual list marker.
This silently corrupted real resume content on AI/PDF import (the path
createResumeFromAIResult -> toListHtml -> toStringArray), e.g.
"3.5 GPA" -> "GPA"
"5 years of experience" -> "years of experience"
"10x improvement in latency" -> "x improvement in latency"
"1000+ users served" -> "+ users served"
"2019 - present" -> "present"
Replace it with /^\s*(?:[-*•]+\s*|\d+[.)]\s+)/, which strips only genuine
markers: bullets ("- * •") or ordered markers ("1." / "2)") followed by
whitespace. Bare leading numbers are preserved, while "- item",
"1. item" and "2) item" are still stripped as before.
Adds a vitest regression test (the repo had no test setup) plus a "test"
script and a minimal vitest config that reuses the existing
vite-tsconfig-paths for "@/" alias resolution.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When importing a resume via the AI / PDF path, list-style fields (experience details, project descriptions, education descriptions, skills) are corrupted whenever a line legitimately starts with a number. Examples of what the import produces today:
This is silent data loss: the user uploads a resume and the imported copy is missing leading numbers that are very common in resume bullets (GPAs, years of experience, metrics, dates).
Root cause
toStringArray()insrc/app/app/dashboard/resumes/utils.tssplits a multi-line string into items and strips a leading list marker from each line with:\d,.and)are inside the same character class with a+quantifier, so the regex greedily removes any run of leading digits / dots / parens — not just an actual list marker. Any line beginning with a number loses that number.This runs on the real import path:
handlePdfFileChange->/api/resume-import->createResumeFromAIResult->toListHtml->toStringArray(the AI is also prompted to returndescription/detailsas text, whichtoStringArrayhandles via its string branch).Fix
Replace the over-greedy class with a regex that strips only genuine list markers:
-,*,•, optionally repeated), or1.,2)) that is digits followed by./)and whitespace.Bare leading numbers are preserved, while
"- item","1. item"and"2) item"are still stripped exactly as before. The only intentional behavior change is that a no-space token like"1.Built"is now kept (it is ambiguous and far more likely real content than a marker).Test
The repo had no test runner, so this PR adds a minimal vitest setup:
vitestdevDependency +"test": "vitest run"scriptvitest.config.tsreusing the existingvite-tsconfig-pathsfor@/alias resolution (no other plugins, so it stays fast and isolated)src/app/app/dashboard/resumes/utils.test.tscovering the regression plus guards that real markers are still stripped and the array/empty branches behave.Verified fail-before / pass-after: with the original regex the regression test fails with
["GPA", "years of experience with Python", "x improvement in latency", "+ users served", "present"]; with the fix all 4 tests pass. The 3 guard tests pass in both states, confirming marker-stripping is unchanged.Repro
5 years of experience,3.5 GPA,10x faster.Or directly:
toStringArray("3.5 GPA\n5 years of experience")returns["GPA", "years of experience"]before the fix and["3.5 GPA", "5 years of experience"]after.Note:
pnpm-lock.yamlchanges are purely additive (vitest and its transitive deps); no existing dependency versions were modified.