Skip to content

Send all top-level file hashes to Hasheous lookup#3498

Merged
gantoine merged 2 commits into
masterfrom
hasheous-lookup-all-hashes
Jun 9, 2026
Merged

Send all top-level file hashes to Hasheous lookup#3498
gantoine merged 2 commits into
masterfrom
hasheous-lookup-all-hashes

Conversation

@gantoine

@gantoine gantoine commented Jun 9, 2026

Copy link
Copy Markdown
Member

Summary

The Hasheous Lookup/ByHash endpoint now accepts an array of hash objects instead of a single one. This updates HasheousHandler.lookup_rom to send the hashes of every top-level file, rather than picking only the largest file and sending its single hash set.

Changes

  • lookup_rom now builds a list payload, one entry per qualifying top-level file:
    • Files with a chd_sha1_hash send only {"sha1": <chd_sha1_hash>} — the raw container MD5/CRC won't match what Hasheous indexes for CHDs.
    • Other files send {"md5", "sha1", "crc"}.
    • Empty hashes are dropped per file; files with no usable hash are skipped.
    • If no file yields any hash, the request is skipped and the fallback is returned.
  • New lowercase key names (md5/sha1/crc) matching the array payload format, replacing the old single-object camelCase keys (mD5/shA1).
  • _request signature widened to accept dict | list | None for the list payload.

Tests

  • test_lookup_rom_sends_all_top_level_file_hashes — verifies the full list payload, chd_sha1_hash-only handling, and that zero-size / hashless files are filtered.
  • test_lookup_rom_skips_request_when_no_hashes — verifies the API isn't hit when no hashes are available.

🤖 Generated with Claude Code

The Hasheous ByHash endpoint now accepts an array of hash objects rather
than a single one. Send the hashes of every top-level file (using
chd_sha1_hash exclusively for files that have one) to improve lookup
accuracy, instead of picking only the largest file.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 9, 2026 11:45

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

Updates the Hasheous metadata lookup to use the new Lookup/ByHash array payload by sending hashes for all qualifying top-level ROM files (including CHD-specific handling), improving match accuracy and avoiding requests when no usable hashes exist.

Changes:

  • HasheousHandler.lookup_rom now builds and sends a list of per-file hash objects (CHD uses sha1 from chd_sha1_hash only; other files send md5/sha1/crc with empty values removed).
  • _request now accepts dict | list | None for JSON payloads.
  • Added tests to validate the list payload and the “skip request if no hashes” behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
backend/handler/metadata/hasheous_handler.py Switches Hasheous ByHash lookup from a single-hash payload to a list of hashes across all top-level files, with CHD-specific hashing behavior.
backend/tests/handler/test_fastapi.py Adds coverage ensuring the full list payload is sent and that requests are skipped when no usable hashes are available.

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

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Test Results (postgresql)

    1 files  ±0      1 suites  ±0   4m 38s ⏱️ +13s
1 581 tests +2  1 581 ✅ +2  0 💤 ±0  0 ❌ ±0 
1 583 runs  +2  1 583 ✅ +2  0 💤 ±0  0 ❌ ±0 

Results for commit 08e8821. ± Comparison against base commit f496038.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Test Results (mariadb)

    1 files  ±0      1 suites  ±0   4m 59s ⏱️ +5s
1 581 tests +2  1 581 ✅ +2  0 💤 ±0  0 ❌ ±0 
1 583 runs  +2  1 583 ✅ +2  0 💤 ±0  0 ❌ ±0 

Results for commit 08e8821. ± Comparison against base commit f496038.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
17096 12387 72% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
backend/handler/metadata/hasheous_handler.py 55% 🟢
TOTAL 55% 🟢

updated for commit: 08e8821 by action🐍

Annotate request_kwargs as dict[str, Any] to accept the list json payload,
and file_hashes as dict[str, str | None] so the chd_sha1_hash branch and the
md5/sha1/crc branch unify cleanly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gantoine
gantoine merged commit 69a7a13 into master Jun 9, 2026
12 checks passed
@gantoine
gantoine deleted the hasheous-lookup-all-hashes branch June 9, 2026 12:08
@michael-j-green

Copy link
Copy Markdown

Regarding:

New lowercase key names (md5/sha1/crc) matching the array payload format, replacing the old single-object camelCase keys (mD5/shA1).

Although it's (supposed to be) case insensitive, I would stick with the original casing.

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.

3 participants