Repository navigation
Integrate nine robustness fixes for 1.6.0 (#107 #208 #209 #210 #211 #231 #234 #236 #240) - #252
Merged
Merged
Conversation
data.result opens with `if result_json:`, and an empty dict is falsy, so a job that finished and produced an empty report skipped the dispatch entirely, failed the "not finished" guard because it had finished, and landed in the else that renders result_invalid.html - "Job ID ... or the result referenced by this job was not found in the system." The reader is told their job does not exist. The tail is now four explicit cases - unknown id, failed or terminated, finished with an empty report, still running - which is also what makes the empty case sayable at all. result_empty.html already existed and already says it. Failed and terminated are checked before finished so a job that is both keeps the answer it had. While in here: the dispatch chain had no else either, so a job method it does not know returned None and Flask answered 500. That is the same crash as the one just fixed in data.linkhunt; nothing reaches it today because the chain covers every method mcrit currently defines, but a new backend method would.
Every unit job on every Python version fails with:
/opt/hostedtoolcache/Python/3.11.16/x64/bin/python: No module named pytest
The Makefile said "pytest and pytest-cov arrive with mcrit, so requirements.txt
covers both". mcrit declares them under its `dev` extra:
$ python -c "import importlib.metadata as m; print(m.requires('mcrit'))"
... 'pytest; extra == "dev"', 'pytest-cov; extra == "dev"' ...
so a plain `pip install -r requirements.txt` does not bring them in, and the
suite has not actually run in CI since mcrit moved them there. Ruff is green
throughout, which is why this looked like a working pipeline.
Installed in the workflow rather than added to requirements.txt: neither is a
runtime dependency and a deployment should not get them. Pinned, for the same
reason the lint job pins ruff. The two stale comments that said otherwise are
corrected.
(cherry picked from commit 8268666)
work/harness/cookies.txt is a cookie jar written by a local debugging harness - a Flask session signed with a secret hardcoded in that harness, against a throwaway SQLite database. Not a credential for anything, but it has no business in this change. It arrived with the cherry-picked CI fix.
Review found this PR fixed empty-vs-unknown and then merged three further
reasons back together.
* A failed or terminated job rendered result_invalid.html, which says the
job "was not found in the system". That is false in both halves: the job
is in the system and the view is holding its Job object. Reporting one
reason as another is the thing the issue is about, so doing it in the
fix was the wrong shape. job_failed.html now says what happened, and
carries the job's own detail table.
* getResultForJob answers None both when the job recorded no result and
when the document behind that id can no longer be fetched - a purged
GridFS entry, a backend re-provisioned with the job metadata intact. The
discriminator, job_info.result, was sitting right there unconsulted, so a
report that merely cannot be retrieved was announced as "Job ID X does
not contain any data". In a triage UI that reads as "your matching run
found nothing", which is a wrong analytical answer rather than wrong
wording. result_invalid.html already says the accurate thing - the result
referenced by this job was not found.
Telling an empty report from an absent one needs the fetch result kept apart
from the cached one, since {} and None are both falsy; `fetched` does that,
and the comment says why it cannot be folded back in.
Also dropped a comment that described an impossible state: is_failed is
attempts_left == 0, decremented only in Job.error(), which never sets
finished_at, so no job is ever both failed and finished.
NOTE: PR #2 needs the same job_failed.html for linkhunt's dispatch and adds
an identical copy, so whichever merges second will conflict add/add on that
one file; either copy is correct.
`init` still ran `pip install -r requirements.txt` alone, so a fresh checkout that follows the README lands without pytest and `make test` fails with "No module named pytest" - the same failure the CI change on this branch fixes for the runner, left unfixed for a contributor. pytest and pytest-cov are not runtime dependencies and are not in requirements.txt; mcrit declares them under its `dev` extra, which nothing here requests, so they do not arrive transitively either. Install them from `init`, pinned to the versions CI uses, and say so once above the target rather than in a comment further down that describes a step that never ran. Reported by Codex review.
Conflicts in tests/testResultPages.py only. Imports are unions. The job page test takes master's parametrized form, after this branch's #73 tests. One collision the conflict markers did not show: master's linkhunt work (1f38998) added test_a_terminated_job_says_it_was_terminated for /data/linkhunt, and this branch has a test of that name for /data/result. Python keeps the later definition, so master's would have stopped running without an error. Renamed this branch's to name the page it covers; ruff's F811 is what caught it. 991 passed, ruff clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011EAW1DRkBwmjZtGzQ5pgDA
Compute the API label flag before either POST branch so malformed ID lists can reach the backend's 400 response. Remove the unused sample search from hash-list cross comparison; its failure path referenced an unbound name and did not affect the redirect. Cover both paths with route tests. Fixes #201
Name the actual ADR files in code comments and keep the linked numbers in AGENTS.md aligned. Add a small reference check so future renumbering cannot leave misleading links behind.
Submit forwarded the binary to the backend but also wrote a SHA-256 named copy under temp/uploads. No route reads that copy; query promotion reads files named by backend job ID. Remove the extra write and cover both mapped and unmapped submissions. Document which existing files can be removed.
Every module under tests/ starts with the shebang and the LOG/logging
boilerplate; this one did not.
The lint also indexed past "{% endif %}" without checking the line had
one, so an icon written with "{%- endif %}" or with its endif on the next
line would have stopped the test with an IndexError instead of failing on
the template line that needs a look.
Every module under tests/ starts with the shebang and the LOG/logging boilerplate; this one did not. Each of the three checks passes on an empty list of matches, so a pattern that stopped matching - a moved docs tree, a new link style - would pass without checking anything. The added test asserts that each pattern still finds references in the searched tree.
With the unbound name fixed, a body that is not an ID list gets the backend's answer. But one that is could still be taken for malformed: the branch matched `request.data`, which Flask leaves empty for a form content type after parsing the body into `request.form`, and a form content type is what `curl --data "1,2"` sends by default. mcrit reads the raw request stream whatever the type, so the same call succeeded against the backend and failed through the passthrough. Read the body with `request.get_data()`, as the binary query branch in this router already does. Measured against mcrit 1.9.0 with `curl -X POST --data 1,2 .../api/functions`: master answers 500 (UnboundLocalError), the previous commit 400, this one 200 with the two functions. A body that is not an ID list still gets the backend's 400.
change_username and change_password ran every check as an independent if, so a malformed username still paid for check_password_hash and a username lookup, and a mismatched confirmation still hashed the old password. The checks now short-circuit. A username change checks the format, then the password, then whether the name is taken - the password deliberately ahead of that cheaper lookup, so that a caller with the wrong password is no longer told whether a name exists. Previously the last failing check won, and "already taken" was shown even when the password was wrong. A password change checks the confirmation, then the password. All three account handlers, regenerate_apitoken included, re-read the caller's row although load_logged_in_user has already read it by the same session id for this request and login_required guarantees it is there. They use g.user now, which also makes the ad-hoc session id validation redundant. Both form routes accepted GET while indexing request.form, so a GET ended in a 400 (a 500 under FLASK_DEBUG). They are POST-only now, as AGENTS.md asks of writing routes; the settings forms already post. Fixes #206.
The link hunt's filter form sends every field, and an empty one parses to None. Both presets set filter_unpenalized_family_count to 2, but a filter the user filled in passed None on to mcrit's getLinkHuntResults, which compares the count to an int: a TypeError, and a 500 for any filter submitted with that field cleared. An empty count now gets the presets' 2, and the form shows it.
job_description groups a cross compare's samples by family, and skipped every sample whose family_id was falsy, which family 0 is. Every mcrit storage keeps family 0 as the unnamed family, and a sample submitted without a family lands in it, so the row of a cross compare over such samples left all of them out, below a count that includes them. Every other description in the template shows family 0 as "Unnamed", through format_family_name, and so does this one now: the check lets through anything but None, the case it was written for.
The dispatch chain in data.result() had no else branch, so a finished job with a result but a method it does not list fell off the end and returned None, which Flask answers with a 500. On a live mcrit 1.9.0 instance that is the result page of each of the three repair jobs (repairMinHashes, recomputeFamilyStats, rebuildPicBlockHashIndex). Answer such a job with result_incompatible.html instead, and cover it with a test using a job method nothing knows.
…#73) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HERmVhHo4ibp7HSTXr3Ya8
… search Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HERmVhHo4ibp7HSTXr3Ya8
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HERmVhHo4ibp7HSTXr3Ya8
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HERmVhHo4ibp7HSTXr3Ya8
…ept only POST Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HERmVhHo4ibp7HSTXr3Ya8
… it empty Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HERmVhHo4ibp7HSTXr3Ya8
…b row Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HERmVhHo4ibp7HSTXr3Ya8
README conflict: both #208 and #211 add an "unreleased" line to the version history; kept both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HERmVhHo4ibp7HSTXr3Ya8
…es not know #107 already contains #240's whole code change (the else branch rendering result_incompatible.html for an unknown job type), so data.py keeps #107's version; the tests keep both sides, so #240's test checks that #107's branch covers its case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HERmVhHo4ibp7HSTXr3Ya8
…r has Since #228 the API passthrough reads Content-Type and the raw body; #208's tests, written before that, failed on the fake lacking both. Test-only change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HERmVhHo4ibp7HSTXr3Ya8
This was referenced Sep 30, 2026
This was referenced Oct 16, 2026
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Nine robustness fixes for 1.6.0, integrated the same way as #248 and #251. Each PR's head commit is an ancestor of this branch, so GitHub marks them merged when this lands with a merge commit.
Resolutions
tests/fixtureData.RawResponse, which predates Forward the backend's bytes through the API passthrough instead of re-encoding them #228. Since Forward the backend's bytes through the API passthrough instead of re-encoding them #228, the API passthrough readsContent-Typeand the raw body. The fake now carries a JSON content type and the payload as bytes. This is a test-only change in its own commit; the other users of the fake are unaffected.elsebranch renderingresult_incompatible.htmlfor an unknown job type).data.pykeeps Tell an empty result apart from a job nobody has heard of (#73) #107's version, and both PRs' tests are kept, so Render a page for a result whose job type the dispatch does not know #240's test now checks that Tell an empty result apart from a job nobody has heard of (#73) #107's branch covers its case.Verified
ruff checkclean.<i {% if %}tags in the tree.Not in this batch
Noneas "renamed".getFamilyalso returnsNoneon a backend 500 or 404, so a failed read-back is reported as "Family modified." when nothing changed. Details on Confirm sample/family modifications instead of sleeping a fixed time #219.views/data.py,views/params.py), so it is added to 16 open PRs need master merged in after #248 #249.🤖 Generated with Claude Code
https://claude.ai/code/session_01HERmVhHo4ibp7HSTXr3Ya8