Skip to content

Report a missing registry file without a traceback - #12

Open
dmccoystephenson wants to merge 1 commit into
mainfrom
feature/cli-missing-registry
Open

dmccoystephenson wants to merge 1 commit into
mainfrom
feature/cli-missing-registry

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

  • main() in src/arcade/__main__.py now catches OSError alongside registry.RegistryError, so a registry path that does not exist or cannot be read is reported by routers, hosts, check-registry and serve as a single arcade: <message> line on stderr instead of a Python traceback. The exit status stays 1, so scripts are unaffected.
  • For serve, RegistryHolder.refresh(initial=True) already re-raises the OSError on first load before anything binds; that error now reaches the same one-line report. A side effect worth noting: any other OSError escaping a handler (for example a bind failure such as "Address already in use" in makeServer) is also printed as one arcade: ... line with exit 1 rather than a traceback.
  • Regression tests added in tests/test_main.py: test_a_missing_registry_is_reported_without_a_traceback (parametrized over routers, hosts, check-registry) and test_serve_refuses_a_missing_registry_before_binding.
  • CHANGELOG.md: a ### Fixed entry under ## [Unreleased]. __version__ is unchanged.

Closes #1

Test plan

  • python3 -m pytest -q: 149 passed locally (Python 3)
  • Regression check: with the __main__.py fix stashed, the 4 new test cases fail; with it restored, they pass
  • CI: test (3.8), test (3.12), docker
  • PYTHONPATH=src python3 -m arcade check-registry examples/games.yaml and black --check could not be run locally in this sandbox. CI runs check-registry, and the diff does not touch the example registry or the parser. The new code was written to black's 110-column style by hand.

No other open issues existed at triage, so none were skipped.

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

main() now catches OSError alongside RegistryError, so routers, hosts,
check-registry and serve print one "arcade: <message>" line (exit 1)
when the registry path does not exist or cannot be read.

Closes #1

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (scored against CI run 37757498918 on the PR head and the diff):

  • Scope: PASS. Three files changed (src/arcade/__main__.py, tests/test_main.py, CHANGELOG.md), each required by CLI prints a traceback when the registry file is missing #1. No formatting or rename churn.
  • Tests-new: PASS. No new public function was added. The one changed behavior (main()'s except clause) is exercised by 4 new test cases.
  • Tests-fix: PASS. With src/arcade/__main__.py stashed, pytest tests/test_main.py -k missing gave 4 failed. With it restored, 4 passed.
  • Sibling structure: PASS. The new tests follow test_an_invalid_registry_is_reported_without_a_traceback and test_serve_refuses_an_invalid_registry_before_binding: same fixtures, same assertions on stderr prefix and empty stdout.
  • Sibling renames: PASS. Nothing was renamed.
  • Docs: PASS. The README does not describe CLI error output, so the only doc that changes is the CHANGELOG ### Fixed entry under ## [Unreleased].
  • Issue resolution: PASS. CLI prints a traceback when the registry file is missing #1 names main()'s except clause and asks for a test in tests/test_main.py. Both are in the diff, and serve is covered too.
  • CI: PASS. test (3.8), test (3.12) and docker all pass.
  • Stdlib-only: PASS. No import lines were added.
  • Py3.8: PASS. Only a tuple in an except clause was added, and test (3.8) is green.
  • Vendored client untouched: PASS. trace_client.py is not in the diff.
  • Naming: PASS. Only test-local missing and argv were added.
  • Isolation headers: n/a. No server.py response path changed.
  • Config documented / CLI documented: n/a. No ARCADE_* variable, subcommand or flag was added.
  • Changelog: PASS. An entry was added under ## [Unreleased], and __version__ is unchanged.

Points for the reviewer:

  • src/arcade/__main__.py:145: catching OSError covers more than the registry read. Any OSError that escapes a handler, such as a bind failure ("Address already in use") from makeServer in serve, now also prints as one arcade: ... line with exit 1 rather than a traceback. This seems a reasonable improvement in the same direction, but the change is wider than the issue's literal wording.
  • black --check and the local check-registry examples/games.yaml invocation could not be run in this sandbox. CI covers check-registry. Black is not enforced in CI, and the added lines are under 110 columns.
  • Out of diff: CHANGELOG.md has no ## [0.6.1] / ## [0.6.2] sections while __version__ is 0.6.3.dev0 and the 0.6.2 release is referenced in history. A separate issue was filed for this rather than editing release sections here.

None of the changed paths is on the do-not-auto-merge list. Merging was not authorized for this dispatch, so the PR is left for a maintainer.

This review was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

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.

CLI prints a traceback when the registry file is missing

1 participant