fix(check_dataset_allowlist): import env_config in both invocation contexts - #255
Merged
Merged
Conversation
…ntexts `autohands check_dataset_allowlist`, newly registered as a CLI verb in #254, crashed with ModuleNotFoundError when run from a workspace root. The two merges combined to expose it: #253 added `from autohands.env_config import ...` to this module, and #254 made it reachable from the dispatcher. `bin/autohands` (`_python_in_autohands`) runs these tools as scripts with `autohands/` ITSELF on PYTHONPATH, so siblings are top-level modules — the flat `from env_config import ...` idiom the other guards here already use. As a library import (pytest, or anything importing `autohands.check_dataset_allowlist`) the package's PARENT is on the path and the flat name does not resolve. Supporting only one form breaks the other, so `_env_config()` tries flat first and falls back to package-qualified. Also fixes a quieter instance of the same bug. `_releasing_tokens` wrapped its import in `except Exception` and returned the hardcoded `{full_datasets, real_output}` fallback, so under the CLI it swallowed the ImportError and never consulted ENV_DECLARATION_TOKENS at all — a silent degradation that still produced a green run, and would have stopped honouring any future releasing token without failing. The fallback is now a genuine last resort. Verified in both contexts: the CLI verb runs clean from a workspace root and still reports the originating defect (exact file, line, resolved path) when that workspace is reverted to its pre-fix state. Suite 375 passed; firewall gate OK. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01F11sMzmaVWfU6NCz1PKVVb
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.
autohands check_dataset_allowlist— newly registered as a CLI verb in #254 — crashes when run from a workspace root:Neither #253 nor #254 was wrong alone; the two combined to expose this. #253 added the
autohands.env_configimport to this module (fine — nothing invoked it as a script). #254 registered it as a dispatcher verb (fine — the module worked at the time it was surveyed). Found immediately after merging both, by actually running the new verb rather than assuming registration made it work.The two paths differ
_python_in_autohandsruns it as a scriptautohands/itselfimport env_configimport autohands.check_dataset_allowlistfrom autohands import env_configThe flat form is the idiom the other guards here already use (
validate_env_profiles.py:48). Supporting only one form breaks the other, so_env_config()tries flat first and falls back to package-qualified.The quieter half
_releasing_tokens()wrapped its import inexcept Exceptionand returned the hardcoded{full_datasets, real_output}fallback. Under the CLI that swallowed theImportErrorand never consultedENV_DECLARATION_TOKENSat all — a silent degradation that still produced a green run.It happened to give the right answer today, because those are currently the two releasing tokens. But the whole point of deriving from the map was that a future token releasing
PYAUTO_SMALL_DATASETSstarts protecting scripts with no edit here — and via the CLI it would have silently kept using the stale pair. The fallback is now a genuine last resort rather than the routine path.This is why the fallback is worth being suspicious of in general: it converted a hard failure into a wrong-but-green one.
Verification
Both contexts, explicitly:
exit=0), and still reports the originating defect with exact file, line and resolved path when that workspace is reverted to its pre-fix state.autohands*imports fail, then asserts_releasing_tokens()still derives from the map rather than the fallback.🤖 Generated with Claude Code
https://claude.ai/code/session_01F11sMzmaVWfU6NCz1PKVVb