Skip to content

Use parsed filename for unmatched ROM titles instead of raw filename#3681

Merged
gantoine merged 4 commits into
masterfrom
posthog-code/fix-unmatched-rom-titles-parsing
Jul 5, 2026
Merged

Use parsed filename for unmatched ROM titles instead of raw filename#3681
gantoine merged 4 commits into
masterfrom
posthog-code/fix-unmatched-rom-titles-parsing

Conversation

@gantoine

@gantoine gantoine commented Jul 5, 2026

Copy link
Copy Markdown
Member

TL;DR
When a ROM scan finds no metadata match, the title should fall back to the parsed filename (with tags and extension stripped) rather than keeping the raw filename as a placeholder. This ensures unmatched ROMs have clean, readable titles for subsequent searches.

Fixes #3665

What changed?

  • Updated ROM creation for unmatched matches (scan.py): Changed the name field to use fs_rom_handler.get_file_name_with_no_tags() instead of the raw filename when creating an unmatched ROM entry.

  • Improved placeholder detection logic (scan_handler.py): Enhanced the logic that determines whether a ROM's existing name is a placeholder:

    • Expanded placeholder detection to recognize both the raw filename and the parsed filename (without tags) as placeholders
    • When updating an unmatched ROM, now falls back to the parsed filename instead of the raw filename if no user-edited name exists
    • Preserves user-edited names while replacing auto-generated placeholders
  • Added test coverage (test_fastapi.py): New test test_scan_rom_unmatched_no_match_uses_parsed_name verifies that:

    • A legacy ROM with a raw filename placeholder gets healed to use the parsed name
    • The parsed name (tags and extension stripped) becomes the fallback title when no metadata match is found

Checklist

  • Changes tested with new unit test
  • Updated relevant comments explaining the placeholder behavior
  • Logic preserves existing user-edited ROM names

Created with PostHog Code

Copilot AI review requested due to automatic review settings July 5, 2026 11:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves how RomM titles ROMs that remain unmatched after a scan by using a cleaned, parsed filename (tags + extension stripped) instead of the raw filename, and updates the “placeholder name” detection so auto-generated names can be safely replaced while preserving user edits.

Changes:

  • Use fs_rom_handler.get_file_name_with_no_tags() as the initial name for newly-created ROM entries during socket scans.
  • Expand placeholder-name detection during UNMATCHED/UPDATE scans to treat both raw and parsed filenames as placeholders and prefer the parsed name as the fallback.
  • Add a unit test ensuring legacy raw-filename placeholders are healed to the parsed filename when no metadata match is found.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
backend/tests/handler/test_fastapi.py Adds a regression test verifying fallback title healing to parsed filename on unmatched/no-match scans.
backend/handler/scan_handler.py Updates placeholder detection and fallback naming behavior during unmatched/update scans.
backend/endpoints/sockets/scan.py Sets newly created ROM name to the parsed filename instead of the raw filename.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backend/handler/scan_handler.py Outdated
gantoine added 3 commits July 5, 2026 07:57
rom_attrs["name"] is seeded from rom.name earlier, so on the no-provider-match
path it still holds the raw filename placeholder. That made the
`or rom_attrs.get("name")` branch win over the fs_name_no_tags fallback,
retaining the raw filename as the title. Treat the seeded name as a placeholder
too, so the parsed filename fallback applies when no provider matched.

Generated-By: PostHog Code
Task-Id: 987bb9c1-1bfb-43f2-adc7-c26e69f06a39
name is NotRequired[str] on HasheousRom, so passing name=None fails mypy's
typeddict-item check. Omit it to represent a no-match result.

Generated-By: PostHog Code
Task-Id: 987bb9c1-1bfb-43f2-adc7-c26e69f06a39
Generated-By: PostHog Code
Task-Id: 987bb9c1-1bfb-43f2-adc7-c26e69f06a39
@gantoine gantoine merged commit 65996ad into master Jul 5, 2026
10 checks passed
@gantoine gantoine deleted the posthog-code/fix-unmatched-rom-titles-parsing branch July 5, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Unmatched ROM titles not parsed

2 participants