fix: harden CLARIN shared surface + dtq owningCollection reauth - #24
Open
jr-rk wants to merge 1 commit into
Open
fix: harden CLARIN shared surface + dtq owningCollection reauth#24jr-rk wants to merge 1 commit into
jr-rk wants to merge 1 commit into
Conversation
Characterization-tested fixes (test written to the intended behaviour first,
then the method corrected) to methods the main-lineage consumers call:
get_bundle_by_name / get_items_from_collection / get_resource_policy
non-200 or empty body -> clean None/[] instead of a NoneType subscript
crash; get_resource_policy also records last_err so a caller can tell an
HTTP error from a genuine empty result.
get_user_by_email 404/any non-200 -> None (+ last_err), not a truthy
uuid-less User that slips past a consumer `if user:` guard.
create_submit_group 201 with an empty body -> None, not Group(None).
add_member post the canonical /eperson/epersons/{uuid} href;
the bare /epersons/ path 404s and DSpace rejects the uri-list.
Group(None) / User(None) empty object, not a TypeError.
get_owningCollection (dtq-only) non-200 -> None + last_err, so ISstag's
src/repo/_audit.py `owning_col is None and last_err.status_code == 401`
reauth retry stops being dead code.
Stacked on the test/CI PR, which supplies the _helpers builders, pytest.ini
markers and the differential-contract job these tests run under. Merge that
PR first. The failure-mode assertions are marked dtq_only (deselected on the
main leg): main carries the same bugs, but propagating these fixes to main is
deliberately out of scope here.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Purpose
The
dspace_rest_client/production fixes that were previously bundled with thetest/CI PR, split out per review so the test PR stays scoped. Stacked on
test/clarin-usage-coverage(base of this PR) — it supplies the_helpersbuilders,
pytest.inimarkers and thedifferential-contractjob these testsrun under. Merge that PR first.
Targets
dtq. The failure-mode assertions aredtq_onlyand deselected on themain leg;
maincarries the same bugs, but propagating these fixes tomainisdeliberately out of scope here.
Fixes (each characterization-tested: test written first, then the method)
get_bundle_by_name/get_items_from_collection/get_resource_policyNoneTypesubscript crash on non-200None/[]get_resource_policyIndexErroron empty policy list; no error/empty distinctionNone, recordslast_errget_user_by_emailUseron 404 (slips pastif user:)None, recordslast_err, no noisy 404 logcreate_submit_groupGroup(None)crash on a 201 with empty bodyNoneadd_member/epersons/{uuid}href → DSpace 422/404/eperson/epersons/{uuid}Group(None)/User(None)TypeErrorget_owningCollection(dtq-only)Collectionon non-200 → ISstag_audit.py401-reauth was dead codeNone+last_errVerified locally
Leg A (full suite,
dtqimpl with these fixes): 137 pass.