Skip to content

test(github): the error-path tests of the GitHub App identity check the whole error #2486

Closed

Description

@dan-petty

Problem Description

The error-path tests and the log test in tests/test_github_app_identity.py do not follow docs/TESTING.md, section "Names and assertions". The rules are:

  • An assertion compares whole values.
  • A test of an error path checks the DevOpsCLIError subclass raised, with its exit code and machine-readable error code.
  • Tuple equality is only for picking fields out of an object whose other fields are noise.

Pull request #2482 added two tests that break these rules:

  • test_an_installation_without_a_requested_permission_fails_naming_the_permissions checks only the class GitHubUnauthenticatedError, and a tuple of three substring booleans on the message. It does not check the exit code or the error code, and it does not compare the whole message.
  • test_a_reply_that_grants_more_keeps_the_token_and_logs_only_the_permission_names checks the log records with the same boolean-tuple pattern, not the whole log message.

The older error-path tests of the same file use the same pattern: test_a_refused_exchange_raises_the_unauthenticated_error_with_githubs_status, test_a_key_that_is_no_rsa_key_fails_before_any_request and test_the_key_without_the_apps_settings_fails_naming_them.

Reproduction Steps

  1. Read docs/TESTING.md, lines 90-96.
  2. Read tests/test_github_app_identity.py at commit 9599ef2, lines 133-174 and 232-272.
  3. The asserts are pytest.raises(<error>) plus tuples of "<text>" in raised.value.message booleans. No test reads exit_code or error_code.

Expected vs Actual Behavior

Expected: each error-path test in the file compares the whole message, the exit code and the error code of the raised error, and the log test compares the whole log message.

Actual: the tests check substrings of the message only, so a change to the exit code, the error code or the rest of the message does not fail them.

Environment Diagnostics

Test code only. No devops command, option or message changes.

Logs, Traces, or Terminal Output

The whole message of the HTTP 422 path at 9599ef2: GitHub App devops-roadmap[bot] has no installation token: GitHub refused POST /app/installations/42/access_tokens (HTTP 422): The permissions requested are not granted to this installation. The installation must grant each permission that the token asks for: actions (read), checks (read), contents (write), issues (write), metadata (read), pull_requests (write). ...

Pre-Submission Checklist

  • I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
  • I have checked existing issues and pull requests to ensure this is not a duplicate.

Source: #2482

Activity

  1. added
    source/agent
    type/test
    status/new
    value/medium
    effort/low
    on Oct 28, 2026
  2. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/test. The change updates test assertions to follow the rules in docs/TESTING.md.
    • Priority: P3-Low. This is a test-quality fix with no user-facing impact and no failing build.
    • Value: Medium. It closes a gap where changes to exit codes or error codes would not be caught by the tests.
    • Effort: Low. A few assertion updates in one test file.
    • Related: test(cli): each test of an error path checks the error code, the exit code or the message, not only the error type #2177, which asks for a different change. Both require error-path tests to check exit code and error code, but #2177 covers all 85 files while the candidate covers only test_github_app_identity.py.
  3. added
    priority/p3-low
    on Oct 28, 2026
  4. added a commit that references this issue on Oct 28, 2026
    eaacf5e
  5. removed
    status/new
    on Oct 30, 2026
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

    effort/lowpriority/p3-lowsource/agenttype/testvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions