Skip to content

Fix skill parsing for skill names containing commas#265

Merged
komalharshita merged 6 commits into
komalharshita:mainfrom
jwalkorat:fix/skill-json-serialization
Jun 5, 2026
Merged

Fix skill parsing for skill names containing commas#265
komalharshita merged 6 commits into
komalharshita:mainfrom
jwalkorat:fix/skill-json-serialization

Conversation

@jwalkorat

Copy link
Copy Markdown
Contributor

Summary

Fixed a bug where skill names containing commas were parsed incorrectly.

Previously, skills were stored as comma-separated strings. This caused problems when a skill itself contained commas, such as "HTML, CSS".

This PR updates the frontend to send skills using JSON.stringify() and updates the backend parser to safely reconstruct the original skill array using json.loads().

A fallback for the previous comma-separated format was also added to maintain backward compatibility.


Related Issue

Closes #188


Type of Change

  • Bug fix — resolves a broken behaviour

What Was Changed

File Change made
static/script.js Updated skill serialization to use JSON.stringify()
utils/recommender.py Added JSON skill parsing with fallback support for old comma-separated strings

How to Test This PR

  1. Run the app:
    python app.py

  2. Open:
    http://127.0.0.1:5000

  3. Add a skill containing commas

Example:
HTML, CSS

  1. Generate recommendations

  2. Verify that:

  • the skill is preserved correctly
  • recommendations still work normally
  • skills are not incorrectly split

Test Results

Tested manually in browser.


Self-Review Checklist

  • I have read CONTRIBUTING.md and followed the guidelines
  • I used the correct branch naming convention
  • I did not add debug statements
  • I only modified files related to this issue

Notes for Reviewer

This implementation fixes the parsing issue without changing the overall recommendation architecture and keeps support for older comma-separated skill formats.

@vercel

vercel Bot commented May 18, 2026

Copy link
Copy Markdown

@jwalkorat is attempting to deploy a commit to the komalsony234-1530's projects Team on Vercel.

A member of the Team first needs to authorize it.

@komalharshita

Copy link
Copy Markdown
Owner

@jwalkorat kindly resolve the merge conflicts

@jwalkorat

Copy link
Copy Markdown
Contributor Author

Hi @komalharshita ,

I have successfully resolved the merge conflicts. The branch is now up to date with the latest changes from main, and all local tests are passing.

@komalharshita komalharshita left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for the contribution — this PR addresses a real edge case and the overall implementation direction is solid.

The issue is correctly identified: comma-separated serialization breaks skill names containing commas, which can corrupt parsing behavior and recommendation input handling.

Switching to JSON-based serialization is a much cleaner and more scalable solution. I also appreciate that backward compatibility was considered through fallback parsing logic instead of introducing a hard breaking change.

What was done well

  • Proper migration away from fragile comma-splitting
  • Defensive malformed-JSON handling
  • Consistent frontend/backend synchronization
  • Backward compatibility support for older values
  • Focused implementation scope without unnecessary refactors

Requested improvements before merge

  • Add automated tests for:

    • valid JSON array parsing
    • malformed JSON handling
    • legacy comma-separated fallback parsing
    • skill names containing commas
  • Briefly document the serialization format change for future contributors.

  • Please verify the duplicated conditional block visible in the diff:

    if (skillsHidden) {

    and ensure no accidental duplicate logic remains after final cleanup/rebase.

Since this touches shared recommendation-input logic, the full recommendation flow should also be manually tested before merge.

Overall, this is a meaningful robustness improvement and should be mergeable after the above refinements.

@jwalkorat

Copy link
Copy Markdown
Contributor Author

Hi @komalharshita ,

Thank you for the review and suggestions.

I have addressed the requested changes:

  • Added automated tests for:

    • valid JSON parsing
    • malformed JSON handling
    • legacy comma-separated fallback parsing
    • skill names containing commas
  • Cleaned the duplicated logic in static/script.js and verified no accidental duplicate if (skillsHidden) or duplicate request logic remains.

  • Added a brief inline note documenting the JSON serialization format and backward compatibility support.

  • Pulled the latest changes from main, resolved branch drift, and re-verified the recommendation flow manually.

Verification:

  • tests/test_basic.py → 44 passed
  • Manual recommendation flow tested successfully

The branch is now updated and ready for re-review.

Thanks again!

@komalharshita komalharshita left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thank you for addressing the previous review feedback.

I re-reviewed the updated implementation and the overall solution looks solid.

What was improved:

  • Replaced fragile comma-separated skill serialization with JSON-based serialization.
  • Preserved backward compatibility through fallback parsing.
  • Added automated tests for:
    • valid JSON parsing
    • malformed JSON handling
    • legacy comma-separated parsing
    • skill names containing commas
  • Removed the duplicate frontend logic previously identified.
  • Added documentation/comments explaining the serialization format.

This is a meaningful robustness improvement and the implementation remains focused on the original issue without introducing unnecessary scope.

The only remaining blocker is that the branch currently has merge conflicts that must be resolved before the PR can be merged.

Please resolve the conflicts, re-run the test suite, and push the updated branch.

Once the conflicts are resolved and CI passes, this PR looks good to merge.

@komalharshita komalharshita merged commit 5c36c99 into komalharshita:main Jun 5, 2026
2 of 3 checks passed
@komalharshita komalharshita added gssoc:approved and removed need review Further information is requested labels Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Skill parsing breaks when skill names contain commas

2 participants