Skip to content

fix(cli): report campus.audit credential-store failures instead of a traceback #57

Closed

Description

@ngjunsiang

Context

The campus audit group (#55) reads and writes the audit API key in the
shared credential store, which is keyring-backed with a file fallback. A
store that cannot be read or written (locked keyring, unreadable
credentials.json) raises CredentialError.

campus audit logout catches it and reports it cleanly, but the other two
paths do not:

  • campus audit login — credentials.set_audit_api_key(...) is
    unguarded, so a store failure escapes as a full Python traceback.
  • get_audit_client() — credentials.get_audit_api_key() (and the URL
    binding read) are unguarded, so every API-backed audit command raises a
    traceback instead of an error message.

The rest of the CLI already treats a credential-store failure as a clean,
reported error; the audit group should match.

Proposed fix

Wrap the credential-store reads and writes in the audit group the same way
campus audit logout already does: catch CredentialError, print an
actionable error with print_error, and exit 1.

Acceptance

  • campus audit login with a store that raises CredentialError exits
    1 with a message naming the failure, and no traceback.
  • An API-backed audit command with a store that raises
    CredentialError exits 1 with a message naming the failure, and no
    traceback.
  • The stored audit key's URL binding read is covered by the same guard.

Activity

  1. ngjunsiang commented on Oct 20, 2026

    @ngjunsiang
    ContributorAuthor

    Fixed by 12b62eb, merged to main via PR #55 (campus.audit command group, #54). Verified: full suite green (293 tests, Python 3.11–3.14 CI), ruff clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions