Skip to content

fix(github): treat the traffic API 403 for integration tokens as expected #2626

Description

@dan-petty

Problem Description

The roadmap Service logs one WARNING for each traffic endpoint, per repository, per metrics cycle. The Service runs with a GitHub App integration token. GitHub returns Resource not accessible by integration (HTTP 403) on each traffic endpoint for an integration token. This restriction is permanent by design. The current code logs a WARNING for each failure and returns zero values. The Service then emits those zeros as PROJECT_TRAFFIC_* gauges, which misrepresents the traffic.

Reproduction Steps

  1. Run the roadmap Service with an integration token.
  2. Start a metrics cycle for a repository.
  3. Read the Service log for traffic WARNING lines.
  4. Confirm the four traffic endpoints each log one WARNING.

Expected vs Actual Behavior

Expected: the Service detects the permanent 403. It logs one DEBUG line per repository. It does not emit the traffic gauges it cannot read.

Actual: the Service logs four WARNING lines per repository, per cycle. It emits zero traffic gauges. The true cause is a token restriction, not a lack of traffic.

Proposed Fix

  1. Detect Resource not accessible by integration in the four traffic calls.
  2. Log one DEBUG line per repository, not four WARNING lines.
  3. Skip the traffic gauges when the API is blocked, instead of emitting zeros.

Environment Diagnostics

  • DevOps CLI Version: 0.15.0
  • Python Version: 3.14.9
  • OS & Architecture: Debian forky/sid, x86_64 (Linux)
  • Execution Environment: GitHub App integration token, roadmap Service

Logs, Traces, or Terminal Output

Failed to query traffic views for dan-petty/devops-cli: gh api call failed with exit code 1: gh: Resource not accessible by integration (HTTP 403)
Failed to query traffic clones for dan-petty/devops-cli: gh api call failed with exit code 1: gh: Resource not accessible by integration (HTTP 403)
Failed to query traffic referrers for dan-petty/devops-cli: gh api call failed with exit code 1: gh: Resource not accessible by integration (HTTP 403)
Failed to query popular paths for dan-petty/devops-cli: gh api call failed with exit code 1: gh: Resource not accessible by integration (HTTP 403)

The four lines repeat for each repository the Service tracks, on every metrics cycle.

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.

Proposed design

Problem statement

The roadmap Service logs four WARNING lines per repository per metrics cycle. GitHub returns a permanent 403 on traffic endpoints for an integration token. The Service also emits zero-valued PROJECT_TRAFFIC_* gauges. These zeros misrepresent the data. The Service should recognize this expected restriction. It should log one DEBUG line and skip the traffic gauges.

Acceptance criteria

Requirement: Detect integration 403 on traffic endpoints

The Service SHALL detect the 'Resource not accessible by integration' error on each of the four traffic API calls.

Scenario: Integration token 403

  • WHEN A traffic API call returns the error message 'Resource not accessible by integration'
  • THEN The Service identifies the error as the expected integration restriction

Requirement: Log one DEBUG line per repository

The Service SHALL log exactly one DEBUG line per repository when the traffic API is blocked by the integration restriction, instead of four WARNING lines.

Scenario: Single debug log

  • WHEN All four traffic API calls return the integration 403 for one repository
  • THEN The Service log contains one DEBUG line and zero WARNING lines for that repository's traffic calls

Requirement: Skip traffic gauges when blocked

The Service SHALL NOT emit PROJECT_TRAFFIC_* gauges when the traffic API is blocked by the integration restriction.

Scenario: No gauge emission

  • WHEN The traffic API is blocked by the integration restriction for a repository
  • THEN No PROJECT_TRAFFIC_* gauge is emitted for that repository

Requirement: Preserve WARNING for other errors

The Service SHALL log a WARNING for traffic API errors that are not the integration restriction.

Scenario: Other error still warns

  • WHEN A traffic API call returns an error that is not 'Resource not accessible by integration'
  • THEN The Service logs a WARNING for that error

Existing Tool Considered

No alternatives check has run. This is the project's own Service code handling a GitHub API error response. No external library covers this specific error-handling behavior. The written cost is minimal: modify the error-handling path in the traffic metrics collection to detect the message string, change the log level from WARNING to DEBUG, aggregate the four calls into one log line, and skip gauge emission. Estimated cost: under 50 lines of changed code, no new dependencies.

Key questions

  • How does the Service detect the integration 403 among other API errors?: Match on the error message string 'Resource not accessible by integration'. The gh CLI wraps all API errors with exit code 1, so the message is the only distinguishing field. Matching on the message avoids false positives from other 403 errors. (best practice) [sources: docs/adr/0002-roadmap-jobs-act-as-a-machine-account.md]
    • Chosen: Match on error message string. The gh CLI always returns exit code 1 for any failure. The message is the only field that distinguishes this 403 from others. The body's log output confirms the message format.
    • Rejected: Match on HTTP 403 status code. The gh CLI does not expose the HTTP status code directly. It wraps the error in its own message. Other 403 errors (rate limit, permission) would also match, causing false positives.
    • Rejected: Match on both message and status code. The status code is not available from the gh CLI output. This option is not implementable with the current error format.
  • What log level does the Service use for the integration restriction?: DEBUG. The restriction is permanent by design. A WARNING for an expected condition adds noise. The body's expected behavior states one DEBUG line per repository. (best practice) [sources: docs/adr/0002-roadmap-jobs-act-as-a-machine-account.md]
    • Chosen: DEBUG. The restriction is permanent and expected. DEBUG keeps the information available without adding noise to the log.
    • Rejected: WARNING. WARNING implies an unexpected condition. This restriction is by design and will never resolve. It adds noise to every metrics cycle.
    • Rejected: INFO. INFO is for notable events. A permanent, expected restriction is not notable. DEBUG is the correct level.
  • What does the Service do with the traffic gauges when the API is blocked?: Skip emission. Emitting zeros misrepresents the data: the cause is a token restriction, not a lack of traffic. The body's expected behavior states the Service does not emit the gauges it cannot read. (best practice) [sources: docs/adr/0002-roadmap-jobs-act-as-a-machine-account.md]
    • Chosen: Skip gauge emission. Zeros misrepresent the data. The true cause is a token restriction, not zero traffic. Skipping is the honest representation.
    • Rejected: Emit zeros with a label. A label could indicate the cause, but it adds complexity. The gauge consumer must handle a new label. Skipping is simpler and more correct.
    • Rejected: Emit zeros as-is. This is the current behavior. It misrepresents the data and is the defect this issue fixes.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

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

    @dan-petty
    OwnerAuthor

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

  3. added
    priority/p2-medium
    scope/github
    on Oct 29, 2026
  4. added
    status/ready
    and removed
    status/new
    on Oct 30, 2026
  5. devops-cli-service commented on Oct 30, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 07fb4c2 (see proposed design in issue body).

  6. added
    status/in-progress
    and removed
    status/ready
    on Oct 31, 2026
  7. removed
    status/in-progress
    on Oct 31, 2026
  8. added a commit that references this issue on Oct 31, 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/p2-mediumscope/githubsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions