Skip CA files that can't be read instead of failing startup, type the
PKI test fixture, and declare certifi as a direct dependency.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
OIDC_TLS_CACERTFILE was handed to httpx as verify=<path>, which builds a
context trusting only that file. A directory needed OpenSSL hashed names,
and DER or .p7b bundles failed to load, so two-tier PKI setups got a 500
on SSO. Build an SSL context from certifi and the system store, then add
every certificate found in the file or directory (PEM, DER, or PKCS#7).
Fixes#1589
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ScreenScraper has no dedicated system for the Commodore 128 or the
Videopac+ G7400, so both reuse a sibling's system ID (C64 and G7000).
The mapping copied the sibling's name too, and since IGDB has neither
platform, that ScreenScraper name won the display-name fallback. The
setup wizard and platform picker then listed the c128 slug as
"Commodore 64" and videopac-g7400 as "Videopac G7000".
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The timeout was checked only after a chunk arrived, so an extractor that
stopped writing blocked the read forever and the deadline never fired. A
watchdog thread now kills the process once the deadline passes.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
When extracting the largest member of a .7z failed partway, the bytes already
streamed stayed in the file and ROM-level hashers, and the raw-archive
fallback was appended on top, giving a hash that matched neither. The hashers
are now restored to their pre-extraction state before the fallback runs.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* perf(scan): download a rom's media files concurrently
download_rom_resources fetched the cover, manual, each screenshot, each
provider media type and every RetroAchievements badge one after another,
so a single ROM never used more than one of the ScreenScraper account's
request slots.
They now download together. ScreenScraper media still goes through its
existing thread and rate limiters, and badges share a new cap of 8 in
flight across all scans. The path columns and changed provider media
dicts are written back in one update.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DAQNWjH7teMsMkFMuUrLTf
* style(tests): sort imports with the Trunk isort config
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DAQNWjH7teMsMkFMuUrLTf
* fix(scan): code-review fixes for concurrent media downloads
- Run provider media dicts one after another, since they share paths
- Await every download before raising the first failure (gather_all)
- Fetch each duplicate media or badge path once (store_ra_badges)
- Reuse store_ra_badges in update_rom
- Share the in-flight test helper and trim comments
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DAQNWjH7teMsMkFMuUrLTf
* refactor(scan): simplify pass on concurrent media downloads
- Move gather_all to utils/concurrency and unpack its results directly
- Let write_file_streamed create the badge directory instead of every badge
- Share the in-flight test helper through tests/concurrency_stubs
- Stub downloads with AsyncMock through one fixture, drop a redundant test
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DAQNWjH7teMsMkFMuUrLTf
* fix(scan): save the paths that landed when a provider download fails
Cover, manual and screenshot paths are written before a provider media or
badge failure is re-raised, so a failure there no longer loses them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DAQNWjH7teMsMkFMuUrLTf
* fix(scan): save each download group's results independently
Paths, provider media and badges each keep their own outcome, and every
change that landed is written before the first failure is re-raised. The
test builds a real Rom instead of a namespace.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DAQNWjH7teMsMkFMuUrLTf
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* chore(mypy): switch to strict mode with listed exceptions
Replace the hand-picked flags with `strict = True`, turning off only the
four flags that aren't clean yet (disallow_any_generics,
warn_return_any, disallow_untyped_calls, disallow_untyped_decorators).
Any other strict flag, including those future mypy releases add to the
preset, is on by default.
That turns on no_implicit_reexport, strict_equality and extra_checks:
- Import each name from the module that defines it. About 240 test
sites patched a dependency through the module that imported it
(`scan_module.fs_rom_handler`); they now import the same object from
its source, so every patch targets what it did before. Tests that
replace a module attribute are unchanged.
- handler.streaming.memory_cards re-exports store_memory_card_version
explicitly, since endpoints call it there and tests patch it there.
- mutagen gets implicit_reexport, as it re-exports without __all__.
- Test comparisons build typed values (CoverResult, a typed expected
dict, enum .value) and the CORS lookup casts for its identity check.
- One ss_handler ** spread keeps a coded ignore: extra_checks wants its
NotRequired dump_* keys spelled out, and the media dict never has them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PLzXae5up2pYXRoBjfjn2G
* chore(mypy): give every generic its type arguments
Drop disallow_any_generics from the strict-mode exceptions and fix the
347 bare generics it reports, 230 of them in app code.
- Bare `dict` becomes `dict[str, Any]`: update payloads, raw provider
JSON and endpoint bodies map string keys to mixed values, so the Any is
real and now written down. The OpenAPI document is unchanged.
- Rom query filters take and return RomSelect; _music_facet_joins and
_exclude_hidden are generic over the Select they're given, and
_build_hash_selects returns id-only selects.
- Redis clients are typed by what they return: the decoding caches are
Redis[str], the RQ connection and binary cache Redis[bytes].
- The rest get explicit parameters: Row, Pattern, ColumnElement,
QueryableAttribute, SpooledTemporaryFile, Task, Future and friends.
Precise types reached callers that had been getting Any, which surfaced:
- The LaunchBox cache writer is fed binary-cache pipelines.
- The flashpoint and IGDB request helpers return raw JSON of varying
shape, not always a dict.
- The rom search endpoint returned dicts under a list[SearchRomSchema]
annotation; it now validates them into that schema.
- The audit filter's id subquery selects strings.
- In tests the binary cache is the non-decoding fake shared with
async_cache, so it is cast to Redis[bytes] rather than changed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PLzXae5up2pYXRoBjfjn2G
* test(upload): assert cleanup against the patched upload directory
The 409 test checked config's ROM_UPLOAD_TMP_BASE while the fixture patches
the endpoint's copy to tmp_path/uploads, so it passed even if cleanup failed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PLzXae5up2pYXRoBjfjn2G
* chore(mypy): keep the row type through the ROM filter helpers
filter_roms and its helpers also receive select(Rom.id) membership queries,
so they now take and return the caller's Select type instead of narrowing to
RomSelect. merged_ra_metadata mixes scalar and list values.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PLzXae5up2pYXRoBjfjn2G
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* chore(mypy): switch to strict mode with listed exceptions
Replace the hand-picked flags with `strict = True`, turning off only the
four flags that aren't clean yet (disallow_any_generics,
warn_return_any, disallow_untyped_calls, disallow_untyped_decorators).
Any other strict flag, including those future mypy releases add to the
preset, is on by default.
That turns on no_implicit_reexport, strict_equality and extra_checks:
- Import each name from the module that defines it. About 240 test
sites patched a dependency through the module that imported it
(`scan_module.fs_rom_handler`); they now import the same object from
its source, so every patch targets what it did before. Tests that
replace a module attribute are unchanged.
- handler.streaming.memory_cards re-exports store_memory_card_version
explicitly, since endpoints call it there and tests patch it there.
- mutagen gets implicit_reexport, as it re-exports without __all__.
- Test comparisons build typed values (CoverResult, a typed expected
dict, enum .value) and the CORS lookup casts for its identity check.
- One ss_handler ** spread keeps a coded ignore: extra_checks wants its
NotRequired dump_* keys spelled out, and the media dict never has them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PLzXae5up2pYXRoBjfjn2G
* test(upload): assert cleanup against the patched upload directory
The 409 test checked config's ROM_UPLOAD_TMP_BASE while the fixture patches
the endpoint's copy to tmp_path/uploads, so it passed even if cleanup failed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PLzXae5up2pYXRoBjfjn2G
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The launch socket payloads, the 409 busy detail and the card-import answer
were hand-written in services/api/streaming.ts and could drift from the
backend models they mirror.
- Publish Socket.IO payload models into the OpenAPI components
(utils/openapi.py), starting with the three streaming launch events.
- Raise the busy 409 from a ContainerBusyDetail model and declare it on
the game and desktop claim routes.
- Derive MemoryCardImport from ClaimStreamingSessionRequest, and type the
list and control calls with their generated response models.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(hltb): accept token-only sessions from /init
HowLongToBeat's /api/search/site/init now returns only a token and the
site's own search sends just x-auth-token. parse_session still required
hpKey and hpVal, so every mint read as "no session" and all HLTB lookups
(and the endpoint discovery workflow) silently returned nothing. The
honeypot pair is now optional and only sent when HLTB issues it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DHm9rRfJsxunF1RckjQqzx
* review: share the honeypot check and narrow optional mock calls
Move the both-fields honeypot check into HLTBSession.honeypot() so the
headers and body cannot drift apart, drop the historical note from its
comment, and assert mock call args are not None before reading kwargs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DHm9rRfJsxunF1RckjQqzx
* feat(hltb): discover the search endpoint from HLTB when GitHub fails
If the endpoint fixture can't be fetched from GitHub, run the same
build-manifest discovery the weekly workflow uses against HLTB itself,
and fall back to the fixture bundled in the image rather than the stale
hard-coded /api/find. The discovery helpers now log instead of printing
so their output joins RomM's logs. Search requests also send an Origin
header, as the browser does for HLTB's same-origin POST.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DHm9rRfJsxunF1RckjQqzx
* fix(hltb): keep a malformed discovery response from aborting scans
parse_session and the discovery validator called .get() on whatever JSON
HLTB returned, so a non-object body raised AttributeError out of
initialize() and aborted the scan. Both now reject non-object JSON, and
the handler logs any discovery failure and keeps the bundled endpoint.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DHm9rRfJsxunF1RckjQqzx
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* fix(roms): order lettered discs like numbered ones
"(Disc A)", "(Disc B)" didn't match the disc tag pattern, so a lettered
set fell back to plain file-name order. A bonus file whose name sorted
earlier could then take the first playlist slot and boot instead of
disc A, and mixed-case names ordered wrongly. Lettered discs now count
from A as 1. The letter needs a space after the word, so "(CDi)" is not
read as disc 9.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkUQt5fewjBenaaUMD4XpG
* fix(roms): match only ASCII letters as a disc letter
With re.I alone, [a-z] case-folds non-ASCII letters too: "(Disc İ)"
crashed ord() with a two-code-point lowercase and "(Disc ſ)" became
disc 287. Also trim the pattern comment and docstring to the repo's
comment limits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkUQt5fewjBenaaUMD4XpG
* fix(roms): keep Unicode whitespace in disc tags matching
re.ASCII on the whole pattern also narrowed \s, so "(Disc 2)" with a
non-breaking space lost its disc number. Scope the ASCII flag to the
disc letter alone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkUQt5fewjBenaaUMD4XpG
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Each user can add channels that forward their notifications: a webhook
posting RomM's JSON (optionally HMAC-signed), a Discord embed or an ntfy
message, or an email address confirmed with a code. A channel filters by
minimum level and by topic, and every stored notification that passes goes
out in its own RQ job, retried three times; ten failures in a row turn the
channel off and tell its owner.
Channel configs are sealed with a key derived from ROMM_AUTH_SECRET_KEY,
since a webhook URL carries its own token. Only an admin's webhooks may
reach private addresses; everyone else's go through the SSRF guard. Email
goes out over the SMTP_* settings, which the heartbeat reports as
NOTIFICATIONS.EMAIL_ENABLED.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A socket joins its user's room, and an admin's the admin room, once at
connect time, so logging out or revoking a user's sessions left their open
sockets receiving notifications and the log stream. Each socket is now
recorded against the login session that opened it, and removing a session
disconnects those sockets on whichever worker holds them.
The main server takes one disconnect handler, so it moves next to the
connect handler and runs the activity cleanup as well.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Labels and the file size read as plain chips now: the tag and weight
glyphs said nothing the text did not. In the resume preview the size
also outranked the labels and the slot while being the least telling
fact about a save, so it drops to the same quiet treatment the list
rows already give it.
`normalize_asset_labels` gains direct unit tests. It is a pure function,
so this covers the trimming, the case-insensitive dedupe and both caps
without a database, where the endpoint tests need one.
`AssetList` gains two regression tests for the fold count, which the
simplify pass rewrote: one asserts only the truly hidden version is
counted, the other that no fold is offered when every version is pinned
on screen. The i18n stub now keeps the pluralisation count so a wrong
one fails.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016bZ7R3xC73MZu1vTNuatPK
The sequential reuse test passes against a non-atomic get-then-delete, so it
did not pin the property the change exists for. The new test rendezvouses both
registrations at the token check and asserts exactly one account is created;
reverting consume to get+delete makes it fail.
Also asserts the hashing path's 7-Zip command terminates switches, since the
real-7zz test only exercises the member-extraction path.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Member names come from the archive's own listing, so an entry stored as
"-x" or "@listfile" was parsed as an option. "--" terminates switch
parsing before the name, matching what the bsdtar path already does.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Annotating it to `read_zip_archive_files`'s own parameters and return type
pins the contract the fake stands in for, rather than accepting anything
through *args.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The size checks around the extraction read `ZipInfo.file_size`, which is
whatever the uploader put in the header, and the check on the finished file
only ran once the member had been written in full. An archive whose method
zipfile cannot decode goes through 7zz, which decompresses it itself and
ignores that header, so a small declared size passed the pre-check while the
real member filled the disk.
Count the bytes as they are written and stop at the cap, which makes the
check on the finished file redundant.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Addresses Copilot review feedback on PR #4617.
The Docker dev image's bind-mounted .git is host-owned while the
romm-dev container runs as root; git 2.35.2+ refuses that mismatch
as "dubious ownership" and rev-parse fails, so GIT_BRANCH silently
stayed null and the UI kept showing "development" in the very
workflow the mount was added for. Pass safe.directory scoped to
this one read-only invocation instead of touching global git config.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TDMqXzXexRgC89YxeNjn9q
- test_git_branch.py: replace the repeated cache_clear()/try/finally
ritual in every test with one autouse fixture.
- useVersionDisplay: href's no-branch fallback now reads version.value
instead of re-deriving the same "branch ?? VERSION" expression from
the raw store a second time.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TDMqXzXexRgC89YxeNjn9q
- AboutDialog's links list was a static array read once at setup, so it
never picked up a later heartbeat update; made it a computed.
- useVersionDisplay's GitHub tree link blanket-encoded the branch name,
breaking "/" as a path separator (e.g. "feature/foo"); now encodes
each segment. Deduped the dev-build/branch check into one computed.
- Trimmed two over-long comments/docstrings per house style.
- Added coverage: a CalledProcessError case for get_git_branch, and a
full test file for useVersionDisplay.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TDMqXzXexRgC89YxeNjn9q
Local checkouts have no release tag, so heartbeat.SYSTEM.VERSION always
falls back to the literal string "development". Add a GIT_BRANCH field
(backend-resolved via git, display-only, not used in the version string
that also feeds outbound User-Agent headers) and use it in the About
dialog and the auth-screen VersionTag so a dev build shows the branch
being worked on instead.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TDMqXzXexRgC89YxeNjn9q
Simplify pass over the animated cover change:
- Encode animated small covers as WebP whatever the source, which drops
the per-format GIF/APNG blending params and makes their WebP copy a
plain file copy.
- Fold the is_animated gate into frame_durations and decode the small
cover's frames in the same pass that reads their durations.
- Write uploaded animated artwork through the atomic write_file.
- Share test fixture constants and the animation encoder, and pin the
per-frame pixel budget with a GIF whose canvas grows mid-animation.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Code-review pass over the animated cover change:
- Cap the pixels decoded across an animation (MAX_ANIMATION_PIXELS),
counted per frame since a GIF canvas can grow mid-animation, so an
oversized animation falls back to its first frame.
- Fall back to the first frame when a later frame fails to decode,
instead of dropping the cover or escaping the error handlers.
- Store uploaded animated artwork as uploaded, like downloaded covers.
- Re-encode composited frames so each replaces the last (no GIF/APNG
ghost trails), and keep GIF loop counts when converting to WebP.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The small cover and the WebP copies were written through PIL, which keeps
only the first frame, so an animated SteamGridDB cover showed as a still
image everywhere once applied. Resize and convert every frame with its
timing, copy WebP sources instead of re-encoding them, and keep all
frames of uploaded animated artwork.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>