Commit Graph

11150 Commits

Author SHA1 Message Date
Georges-Antoine Assi
e8993c1d4d run fmt 2026-08-07 14:37:11 -04:00
Sam Dornan
4e149fb707 fix(hltb): redact session material from the request debug log
The debug log printed the session headers and the honeypot pair verbatim.
The token decodes to "<issued-at>::<public IP>|<user agent>|<key>|<hmac>",
so anyone pasting DEBUG logs into a bug report published their host's public
IP address. Logs are also downloadable through /api/logs.

Redact the session headers and drop the honeypot entry from the logged
payload, keeping the URL, search terms and timeout that make the line useful.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-06 12:48:59 -05:00
Sam Dornan
39d7fa0b0f fix(hltb): read the session after pacing, and pace renewals too
Addresses review feedback on concurrent scans (SCAN_WORKERS > 1), where the
handler singleton is shared across in-flight ROM lookups.

Read the session after awaiting the rate limiter rather than before, so a
request paced behind a peer's renewal uses the current session instead of the
one that was live when it queued, and bails out if the session went away.

Acquire the limiter before the /init renewal as well, so a wave of concurrent
403s can't burst past the cap that search requests respect. The endpoint
fixture fetch is left unpaced: it targets GitHub, not HLTB.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-06 12:48:59 -05:00
Sam Dornan
24d990f21a fix(hltb): renew rejected HLTB sessions instead of failing the scan
HLTB sessions are short-lived and pinned to the requesting IP address and
user agent. The handler fetched one session at the start of a scan and never
renewed it, so once HLTB rejected it every remaining lookup failed for the
rest of the scan.

Retry with a renewed session on 403, and back off and retry on 429. Report
the actual cause instead of mapping every HTTP error to "check your internet
connection", which is now used only for genuine connect and timeout errors.

Also fixes two adjacent bugs:

- The honeypot key was written into the caller's payload dict in place. That
  key rotates with the session, so a renewal would leave the dead key in the
  body alongside the new one.
- heartbeat() sent no user agent. HLTB rejects requests without one, and the
  httpx default only happens to be accepted today.

initialize() is now async so the session can be renewed from the async
request path, and uses the shared context httpx client.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-06 12:48:59 -05:00
Georges-Antoine Assi
19c88ef755 Merge pull request #4119 from rommapp/dependabot/npm_and_yarn/frontend/socket.io-parser-4.2.7
chore(deps): bump socket.io-parser from 4.2.6 to 4.2.7 in /frontend
2026-08-05 07:14:05 -04:00
Georges-Antoine Assi
b68b75ba9c Merge pull request #4118 from rommapp/dependabot/npm_and_yarn/frontend/fast-uri-3.1.5
chore(deps-dev): bump fast-uri from 3.1.4 to 3.1.5 in /frontend
2026-08-05 07:13:47 -04:00
dependabot[bot]
84f0c35c5b chore(deps): bump socket.io-parser from 4.2.6 to 4.2.7 in /frontend
Bumps [socket.io-parser](https://github.com/socketio/socket.io) from 4.2.6 to 4.2.7.
- [Release notes](https://github.com/socketio/socket.io/releases)
- [Changelog](https://github.com/socketio/socket.io/blob/main/CHANGELOG.md)
- [Commits](https://github.com/socketio/socket.io/compare/socket.io-parser@4.2.6...socket.io-parser@4.2.7)

---
updated-dependencies:
- dependency-name: socket.io-parser
  dependency-version: 4.2.7
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-05 01:56:33 +00:00
dependabot[bot]
67658439d3 chore(deps-dev): bump fast-uri from 3.1.4 to 3.1.5 in /frontend
Bumps [fast-uri](https://github.com/fastify/fast-uri) from 3.1.4 to 3.1.5.
- [Release notes](https://github.com/fastify/fast-uri/releases)
- [Commits](https://github.com/fastify/fast-uri/compare/v3.1.4...v3.1.5)

---
updated-dependencies:
- dependency-name: fast-uri
  dependency-version: 3.1.5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-05 01:56:15 +00:00
Georges-Antoine Assi
163dcde8cb Merge pull request #4113 from Spinnich/fix/gallery-random-stale-platform
fix(v2): drop a random pick after leaving the platform
2026-08-04 21:54:34 -04:00
Georges-Antoine Assi
70f47fa3aa Merge pull request #4115 from rommapp/dependabot/uv/aiohttp-3.14.3
chore(deps): bump aiohttp from 3.14.1 to 3.14.3
2026-08-04 21:54:02 -04:00
Spinnich
ccf3582b1a fix(v2): mirror the stale pick failure guard in the collection gallery
The collection gallery carried the same unconditional error handler, so a
request that rejected after the user switched collections raised a snackbar
for the one they left.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-04 23:09:36 +00:00
Spinnich
65db3a0c2d fix(v2): keep a stale random pick failure quiet
A request that rejects after the user switched platforms reached the
unconditional error handler, so an abandoned platform could still raise a
snackbar. Gate it on the same staleness check the success path uses.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-04 23:09:36 +00:00
Spinnich
b4519eda71 fix(v2): drop a random pick after leaving the platform
The platform gallery's Random ROM button never re-checked which platform
was on screen when its request came back, so a pick started before
switching platforms still navigated, landing the user in a game from the
gallery they had left. Capture the platform id at click time and abandon
the pick once it no longer matches, the same guard the collection gallery
already carries.

Fixes #4104

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-04 23:07:16 +00:00
Georges-Antoine Assi
7562195fc6 ci(e2e): stop the backend before post-job cleanup
setup-uv prunes the uv cache in its post-job hook whenever the cache key
misses, which happens on any change to uv.lock or pyproject.toml. The
backend is started with `uv run main.py` and left running, and `uv run`
holds the uv cache lock for its whole lifetime, so the prune blocks until
the runner kills cleanup at the 5 minute cap and the job fails with
`uv failed with exit code 2` despite every test passing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-04 19:06:46 -04:00
Georges-Antoine Assi
5f61452865 Merge pull request #4110 from Spinnich/fix/home-rows-skip-total
perf(home): stop counting the whole library for the two home rows
2026-08-04 17:57:03 -04:00
Georges-Antoine Assi
c639923d7f Merge pull request #4097 from Spinnich/fix/gallery-random-rom-perf
perf(gallery): resolve the random rom button in one request
2026-08-04 17:56:16 -04:00
dependabot[bot]
7bd3f64b0b chore(deps): bump aiohttp from 3.14.1 to 3.14.3
Bumps [aiohttp](https://github.com/aio-libs/aiohttp) from 3.14.1 to 3.14.3.
- [Changelog](https://github.com/aio-libs/aiohttp/blob/master/CHANGES.rst)
- [Commits](https://github.com/aio-libs/aiohttp/compare/v3.14.1...v3.14.3)

---
updated-dependencies:
- dependency-name: aiohttp
  dependency-version: 3.14.3
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-04 21:21:11 +00:00
Spinnich
dbd213c6c9 perf(home): stop counting the whole library for the two home rows
The "Recently added" and "Recently played" rows each ask for 15 games and
render 15 covers, but both requests still made the server count every game
in the library and then discarded the number. On a large library that count
is the expensive part of the request, so opening the home page paid for two
whole-library counts nobody sees.

Both rows now send with_total=false, the option added for the gallery in
#4062.

The flag has to reach the request and the cache-clear pattern together: the
pattern is matched against the cache key by substring, so adding it to only
one side would leave the row permanently stale. The cached service now
builds both from a single parameter map per row so they cannot drift, and
the tests assert the clear pattern still matches the key the request writes.

Fixes #4099

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-04 17:20:23 +00:00
Spinnich
5521b851b8 perf(gallery): resolve the random rom button in one request
The platform and collection "Random ROM" buttons asked the API for the
scope total, then for the single row at a random offset, and neither call
opted out of the char index, the filter values or the rom id index. All
three cover the whole result set, so picking one game did about as much
work as loading the entire gallery. Scoped requests are never cached
either, so the full cost came back on every click: on an 83,000-game
instance, 7.19s and 878KB against 0.27s and 16.9KB for the same request
with the sidecars off.

Both buttons now call GET /api/roms/random, which samples on the primary
key and returns one row. The scope parameters it already accepts cover
the platform id and all three collection kinds, so the collection view
keeps its kind split unchanged and null stands in for an empty scope.

The v1 RandomBtn / ContextualRandomBtn share the old shape and are left
alone, since v1 is frozen.

Fixes #4068

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-04 13:21:54 +00:00
Georges-Antoine Assi
906a1c0533 Merge pull request #4086 from bikeborb/fix/csrf-anonymous-stale-token
fix(auth): accept a stale user-bound CSRF token on anonymous requests
2026-08-04 08:31:34 -04:00
Georges-Antoine Assi
d67dde2226 Merge pull request #4078 from Spinnich/fix/metadata-sort-perf
perf(roms): sort metadata fields on the indexed roms column
2026-08-04 08:25:30 -04:00
Georges-Antoine Assi
d874cc1738 Merge pull request #4071 from Spinnich/fix/random-pick-constant-time
perf(roms): pick a random rom without paging to a random offset
2026-08-04 08:25:07 -04:00
Georges-Antoine Assi
042a36240f Merge pull request #4069 from Spinnich/fix/home-setup-library-scan
fix(home): stop scanning the library filesystem on every home page load
2026-08-04 08:24:39 -04:00
Spinnich
28739f93df chore(roms): trim the comments on the metadata sort columns
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-04 12:14:08 +00:00
Spinnich
b6d43ce73c chore(roms): drop the comment on the random rom api wrapper
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-04 11:24:06 +00:00
Spinnich
d095f87feb refactor(home): reuse get_roms_count for the setup-library bail-out
Swap the purpose-built has_any_rom() probe for the existing
db_stats_handler.get_roms_count(), per review. The count is already
served from an index-only scan and backs the stats endpoint, so it
carries the same cost here without adding a second way to ask the
database whether the library has been scanned.

Leaves roms_handler.py untouched by this branch.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-04 11:01:22 +00:00
bikeborb
a2a4cccb51 Update backend/handler/auth/middleware/csrf_middleware.py
Co-authored-by: Georges-Antoine Assi <3247106+gantoine@users.noreply.github.com>
2026-08-03 22:49:59 -04:00
Georges-Antoine Assi
071e82adad Merge pull request #4083 from Spinnich/fix/v2-hash-copy-and-firmware-hashes
fix(v2): make hashes recoverable without HTTPS and show all firmware hashes
2026-08-03 21:48:41 -04:00
Georges-Antoine Assi
985fefb984 Merge pull request #4093 from rommapp/fix/rq-worker-redis-url-env
fix(docker): keep the Redis password out of the RQ worker command line
2026-08-03 21:29:20 -04:00
Georges-Antoine Assi
0c16efd6bb Merge pull request #4090 from XenuIsWatching/fix/batocera-config-invalid-slugs
fix(config): map tic80 to the tic-80 platform slug
2026-08-03 21:25:37 -04:00
Georges-Antoine Assi
76efbe72fd fix(docker): keep the Redis password out of the RQ worker command line
The worker received its connection string through `rq worker --url`, which
put the password in argv for the life of the process, readable via
/proc/<pid>/cmdline, ps, and any monitoring or diagnostic tooling that
collects command lines (CWE-214).

RQ's `--url` option already reads from RQ_REDIS_URL, so passing it through
the environment instead is behavior-preserving. This matches how the RQ
scheduler alongside it already takes its credentials.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-03 21:24:31 -04:00
Ryan McClelland
bee884a371 fix(config): map tic80 to the tic-80 platform slug
The Batocera example bound the tic80 folder to "tic", which is not a
platform slug RomM knows. A binding to an unknown slug still applies, so
the platform is created with that slug, matches no metadata provider, and
is named from the string itself rather than being identified.

The real slug is tic-80.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-03 12:14:42 -07:00
Dakota Brown
b53c7cf98a fix(auth): accept a stale user-bound CSRF token on anonymous requests
Logging in failed once with a CSRF error and succeeded on retry.

`_csrf_tokens_match` validates the user id embedded in the token against
the current request's user. A browser holding a token bound to user N,
whose server-side session is gone (container restart, session expiry,
Redis flush), makes an anonymous login POST. N != None, so the request is
rejected. The rejection response then rotates the cookie, which is why the
second attempt works.

Keep the double-submit check and the cookie/header user agreement
unconditionally, and enforce the caller binding only when there is a
caller. An anonymous request cannot be forged this way regardless: an
attacker cannot read the cookie cross-origin, so it cannot produce the
matching header.

This is the mirror of #3420, which fixed the authenticated direction by
rotating the cookie on safe requests. That path is untouched here, and
test_authenticated_user_binding_still_enforced pins it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-03 12:41:12 -04:00
Spinnich
c8ab8dda9d fix(v2): order the ROM metadata hashes like the rest of the UI
The files list and the firmware list both read SHA-1, CHD SHA-1, MD5, CRC,
RA. The metadata tab led with CRC instead, so the same hashes appeared in a
different order depending on which tab the user was on.

Covers the ordering with a unit test, including the CHD SHA-1 position: the
mock library holds no CHD, so that branch cannot be reached in a browser.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-03 16:15:35 +00:00
Spinnich
959e5c0db9 fix(v2): label the ROM metadata hash row SHA-1 to match every other surface
MetadataTab was the only place labelling the row SHA1, while FileRow,
FilesSummary and the firmware list all use SHA-1. It was also inconsistent
within its own list, sitting directly beside a CHD SHA-1 row.

The label is hardcoded rather than translated, so no locale changes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-03 16:05:55 +00:00
Spinnich
f815c77ca0 fix(v2): make hashes recoverable without HTTPS and show all firmware hashes
The Clipboard API only exists in a secure context, so over plain HTTP the
copy button on a hash chip always failed. Because the displayed value is
abbreviated in JavaScript, the rest of the hash was never in the DOM
either, leaving the full value unreachable on any HTTP install.

Clicking a chip now reveals the full value as selectable text whenever a
copy cannot land, so Ctrl+C works as a fallback. On HTTP the click no
longer attempts the doomed copy, so the misleading error toast is gone.
Behaviour over HTTPS is unchanged apart from revealing when a copy throws.

The firmware tab only ever showed the MD5, as an unselectable chip with no
copy affordance, while the stored CRC and SHA-1 were never displayed. All
three now render as copyable chips, matching the ROM files tab.

Fixes #4082

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-03 15:35:41 +00:00
Spinnich
6f167afeb8 perf(roms): sort metadata fields on the indexed roms column
Ordering the gallery by a `roms_metadata` field joined the view back in and
sorted through it. `roms_metadata` is a thin view over STORED generated
columns on `roms` (migration 0098), so that join is `roms` to itself and it
leaves the sort key on a joined table, which no index can serve: the engine
filesorts the whole library for every page.

The generated columns are already indexed, so the three that are offered as
sorts now resolve straight to them and the join goes away. On a 120k-row
table this turns a full scan plus filesort into a 72-row index walk.

The remaining view columns are JSON arrays with no index and no sort that
offers them, so they keep reading the view.

Fixes #4067

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-03 02:03:48 +00:00
Spinnich
7bbf94c08c fix(roms): re-check visibility on the random pick after fetching
The id comes from a permission-filtered query but the row is fetched by
raw id, so a rom that moved to a hidden platform in between was picked
under its old one and would serialize under its new one. Re-check the
loaded row against the caller's permissions, as every other raw-id rom
lookup does.

Returns null rather than raising 404: it keeps a hidden rom
indistinguishable from an empty scope, and keeps an error path out of a
contract that otherwise has none.
2026-08-02 20:04:30 +00:00
Spinnich
1ee6cea070 perf(roms): pick a random rom without paging to a random offset
The Home "Random Pick" widget asked the API for the library total, then
for the single row at a random offset. Paging to offset N makes the
database walk and discard the N rows before it, so the pick got slower
the bigger the library: measured on an 83,000-game instance, 1.7s at the
median offset and 6.9s deep into the list, on every home page visit.

Adds GET /api/roms/random. It offers the query a batch of random primary
keys and takes any that exist, which is one index lookup per candidate
and unbiased, since every id in the table is equally likely to be
offered. A batch only misses when the query matches too little of the id
space, and it then falls back to counting the set and taking the row at a
random position, reading index entries rather than rows because the
statement selects nothing but the id. Both paths are uniform.

On the same 83,000-game library: 2.9ms median for an unscoped pick
(0.6% of picks take the fallback, 236ms), 19-25ms scoped to a platform.
The widget now resolves a pick in one request.

The endpoint takes the platform / collection scope parameters so the
gallery "Random ROM" buttons (#4068) can move onto it too.

Fixes #4066

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-02 19:25:36 +00:00
Georges-Antoine Assi
e7c2362527 Merge pull request #4065 from rommapp/fix/server-stats-legibility
fix(stats): pluralize the platform game count and lift meta legibility
2026-08-02 14:04:23 -04:00
Spinnich
e85f2fe4ef fix(home): stop scanning the library filesystem on every home page load
The v2 home page requested GET /api/setup/library on every visit, which
walks every platform directory under the library path to count files.
That hint only exists for brand-new instances, but it fired for everyone:
17s per home page load on an 83k-game library, 38s on slower storage, and
the result was thrown away because the library wasn't empty.

The frontend watcher was wired to `isEmpty` with `immediate: true`, so it
ran during setup, before any of the page's data requests had started. All
the `fetching*` flags were still false and the stores were still empty, so
the library looked empty and the walk kicked off.

Frontend: onMounted now awaits the initial fetches and flips an
`initialLoadDone` flag. The watcher and the empty-state `v-if` both gate on
`initialLoadDone && isEmpty`, so the request and the render can no longer
disagree about whether the library is empty.

Backend: get_setup_library_info() returns early with an empty
`existing_platforms` once the database holds ROMs, since the on-disk hint is
meaningless then. Gated on ROMs alone, not platforms: platform rows with
zero ROMs are exactly the case the hint exists for, so those still walk.

Fixes #4063

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-02 16:34:15 +00:00
Georges-Antoine Assi
361b2414d3 fix(stats): pluralize the platform game count and lift meta legibility
Server Stats rendered "1 games" for a single-game platform, and the row
meta line leaned on the faint foreground tier: the middot separator, the
size percentage and the region expand toggle all sat at the edge of
readability.

- Pass the count as vue-i18n's plural choice and give every locale the
  plural forms its `collection.games-count` sibling already uses.
- Draw the separator as a 4px dot in the muted tier instead of a thin
  middot glyph, and move the size percentage off the faint tier.
- Outline the region expand/collapse control so it reads as a button,
  and label it for screen readers.
- Spell out the coverage tooltip as "IGDB matches: 159 / 227".

Fixes #4057

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-02 12:18:53 -04:00
Georges-Antoine Assi
4fac604e65 Merge pull request #4062 from Spinnich/fix/gallery-window-skip-total
perf(roms): let a gallery window fetch skip the library count
5.1.1-beta.1
2026-08-02 11:00:51 -04:00
Georges-Antoine Assi
1e514ec273 chore(roms): drop redundant comments on the total opt-out
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 20:27:57 -04:00
Georges-Antoine Assi
43cdd0856a refactor(roms): resolve the page total in a helper
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 19:59:29 -04:00
Georges-Antoine Assi
79a8322470 Merge pull request #4060 from rommapp/fix/hasheous-mameredump-verified
fix(hasheous): read the CHD and DOS signature sources
2026-08-01 19:48:56 -04:00
Georges-Antoine Assi
509e4d156d fix(hasheous): keep unverified ROMs that predate a match key
`hasheous_metadata` gains keys as RomM maps more of Hasheous' signature
sources, so rows written before `mame_redump_match` existed don't carry it.
On PostgreSQL `hasheous_metadata->>'mame_redump_match'` is then NULL, the OR
chain over the match flags evaluates to NULL instead of false, and `NOT (...)`
stays NULL: the unverified filter returned nothing for those rows until they
were rescanned.

Each extraction is now coalesced to false. The JSON path is untouched, since
SQLAlchemy compiles `as_boolean()` to a CASE whose ELSE branch already folds a
missing key into false.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 19:31:32 -04:00
Georges-Antoine Assi
0b816f0ceb Merge pull request #4058 from rommapp/fix/manual-viewer-mobile-height
fix(rom-details): render the manual viewer on mobile
2026-08-01 19:07:00 -04:00
Spinnich
0be6e3a70f perf(roms): let a gallery window fetch skip the library count
Opting out of the rom id index made the endpoint fall back to a COUNT
over the whole filtered set, so every scroll batch re-derived a total
the page already had from its bootstrap.

Add a with_total flag that skips that count, and have the v2 gallery's
window fetch pass it alongside the sidecar opt-outs it already sends.
total comes back null there, which the store's existing guard leaves
alone rather than applying over the size it knows.

Fixes #4053

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-01 23:00:38 +00:00
Georges-Antoine Assi
56f8a51e04 fix(hasheous): read the CHD and DOS signature sources
The match flags on `hasheous_metadata` are keyed off Hasheous'
`SignatureSourceType` names, and two never lined up with what its API
actually returns:

* `MAMERedump`, the source holding Redump's disc images in CHD form, was
  mapped to nothing at all. A CHD identified by its disc-data SHA1 matched,
  got its metadata, and still read as unverified because no flag was set.
* `puredos_match` looked for `PureDOS`; the source is named `PureDOSDAT`, so
  the flag was pinned to False for every ROM.

CHD matches now set `mame_redump_match`, which the verified filter counts and
which the Metadata tab folds into the existing Redump chip (same database,
different distribution format). Existing rows pick the flag up on their next
rescan.

Hasheous also exposes Pleasuredome, TotalDOSCollection, eXo, ScreenScraper and
Generic sources that RomM still maps to nothing; those are left alone since
folding them in widens what "verified" means.

Fixes #4030

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 18:10:16 -04:00