Repository navigation
fix(dincli): initialize the registry contract on the register-request --manifestCID route - #297
Conversation
… --manifestCID route The lookup sat inside the `if not manifestCID:` branch, so `--manifestCID` reached the openSourceFee()/proprietaryFee() call with dinregistry_contract unbound and died with an UnboundLocalError before any transaction was sent. Resolve the contract before the branch, as update-manifest-request already does, and cover the CID route with a unit test.
The previous run's only failure was 'missing proxyAdmin in foundry/deployments/localhost.json' in test_01_platform.py, a foundry deploy step this branch does not touch (the diff is one statement moved earlier in dincli register-request plus a unit test). Re-running for a clean signal.
|
Reviewed against CI on Claimed: Verified — correct: on Claimed: moving the lookup above the branch mirrors Verified — correct: Claimed: the new Verified — break-then-fix: with Claimed: no new test failures. Verified — Linux, full suite: Not independently re-verified: a live Every checkable claim held up. Mergeable as-is; GitHub shows |
Files changed (2) — as of
|
| Field | Value |
|---|---|
| Change | Modified |
| Lines | +2/-2 |
| Diff (what exactly is in this PR) | Moves dinregistry_contract = ctx.obj.get_deployed_din_registry_contract() from the end of the if not manifestCID: block in register_request to just after get_en_w3_account_console(), before the task-coordinator/auditor resolution. |
| Functionality — how & why | How: register_request now resolves the registry contract unconditionally. Both routes (manifest file → IPFS upload, or a caller-supplied --manifestCID) then reach the same openSourceFee()/proprietaryFee() call, requestModelRegistration(...) tx and ModelRegistrationRequested receipt parse with the contract bound. Why: on the CID route the block that assigned it was skipped, so the fee lookup raised UnboundLocalError before any tx (issue No. 295). This matches update_manifest_request, which already resolved the contract before its branch. |
Diff vs current develop HEAD |
None — untouched since merge-base. |
| Recommended merge proposal | Merged as-is. Break-then-fix confirmed: develop's version of this file makes the new test fail with the reported UnboundLocalError; the PR's version passes. |
| Actual merge proposal | Merged as-is (path B, local merge by @umeradl) in e9424af; no deviation commit. |
| Pending proposal | None |
| Local merge conflict | No |
| GitHub merge conflict | No |
tests/test_register_request_cid.py
| Field | Value |
|---|---|
| Change | New |
| Lines | +65/-0 |
| Diff (what exactly is in this PR) | Regression test: calls register_request directly with a SimpleNamespace ctx.obj (mocked registry contract, w3, account, console that auto-confirms) on the --manifestCID route, with get_bytes32_from_cid and build_and_send_tx patched. |
| Functionality — how & why | How: asserts get_deployed_din_registry_contract() is called exactly once, build_and_send_tx is reached once, and the tx value equals the mocked proprietaryFee(). Why: locks in the CID route so the lookup can't drift back inside the file-route branch, and checks the fee wiring, not just the absence of a crash. |
Diff vs current develop HEAD |
None — file doesn't exist on develop. |
| Recommended merge proposal | Merged as-is. Passes locally (1 passed); full pytest -m "not integration": 540 passed, 0 failed. |
| Actual merge proposal | Merged as-is (path B, local merge by @umeradl) in e9424af; no deviation commit. |
| Pending proposal | None |
| Local merge conflict | No |
| GitHub merge conflict | No |
Verification
CI on d1b6bdc (tree identical to head 9ccf090, which is an empty commit): CI OK green. Locally: break-then-fix of the new test, plus a full pytest -m "not integration" run, 540 passed. Full detail is in the verification comment above. The non-blocking Integration (full GI) failure (missing proxyAdmin) is pre-existing tests/dincli drift, unrelated to this diff.
Local vs. GitHub agree: both clean; GitHub's BEHIND reflects only a disjoint docs commit on develop.
Actual outcome — PR No. 297 merged as-isThis supersedes the pre-merge review comment above with what actually happened when merging this PR into One commit, on
Files unchanged from the PR (2 of 2)
Verification
Local vs. GitHub agree: clean merge as predicted. Issue No. 295 can now be closed, and the |
|
Note on the outcome comment above: "CI green" refers to |
…InfiniteZeroFoundation#297) Issue InfiniteZeroFoundation#295's UnboundLocalError was fixed by PR InfiniteZeroFoundation#297 (develop@e9424af) and the issue is closed, so the WARNING block telling readers to avoid --manifestCID is now stale. Document both --manifestpath/--manifestCID routes in register-request's usage block instead, matching how update-manifest-request already shows them, with a one-line note on what --manifestCID does differently (skips the IPFS upload). cli-reference.md and workflows/model-workflow.md were checked for the same warning; neither has one. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Problem
dincli task model-owner register-request --manifestCID <cid>crashed withUnboundLocalError: cannot access local variable 'dinregistry_contract' where it is not associated with a valuebefore any transaction was sent (issue #295). The manifest-fileroute (
--manifestpath) worked.Root cause
The
dinregistry_contract = ctx.obj.get_deployed_din_registry_contract()lookup sat insidethe
if not manifestCID:branch, so the CID route skipped it, and the later fee lookup(
openSourceFee()/proprietaryFee()) read an unbound local.update-manifest-requestalready resolves the contract before its own branch.Fix
Move the lookup above the
if not manifestCID:branch, mirroringupdate-manifest-request. The manifest-file path is unchanged: it still reaches the samelookup, now resolved once instead of inside the branch.
Testing
tests/test_register_request_cid.py: callsregister_requestwith amocked
ctx.objand a--manifestCIDargument, asserting the command runs tobuild_and_send_txwith the fee fromproprietaryFee(). It fails withUnboundLocalErrorat the fee lookup on unpatcheddevelopand passes with the fix.pytest -m "not integration" -q: 432 passed, 1 failed → 18 failed / 12 errors, allpre-existing on this Windows machine (identical set on unpatched
develop: Unix-onlypermission bits, symlinks, anvil/ipfs/forge tooling; 3 more modules can't collect without
torch). The new test accounts for the +1 pass; my change adds no failures.ruff check dincli/cli/task.py tests/test_register_request_cid.py: the 28 findings intask.pyare identical on unpatcheddevelop(CI runs ruff as advisory); the new testfile is clean.
Fixes #295