Skip to content

Issue the job token for the job's own timeout-minutes; keep a workflow's own enterprise token #70

Done

Description

@waynesun09

What happens

The upstream-runner job token lives for a job's timeout plus 5 minutes, capped at 24 hours (job_token_service.job_token_lifetime). It reads timeout_minutes from the job, but WorkflowJob has no such column. workflow_service parses timeout-minutes into the job dict and never stores it.

So every job's token uses the default: 360 + 5 minutes.

Job Token lifetime Effect
timeout-minutes: 30 365 min Longer than the job may run
timeout-minutes over 360 365 min Expires before the job may end. From plan version 8, the job's completion report then gets 401

GitHub's job token is valid until the job ends.

A second, smaller item in the same area: _with_gh_enterprise_token mirrors GH_TOKEN/GITHUB_TOKEN into each enterprise variable separately. A step that sets only GITHUB_ENTERPRISE_TOKEN still gets GH_ENTERPRISE_TOKEN mirrored from GH_TOKEN. gh reads GH_ENTERPRISE_TOKEN first, so it uses the mirrored token, not the one the workflow chose.

Proposed change

  1. Add workflow_jobs.timeout_minutes (nullable integer, NULL = default), with a migration on the current Alembic head.
  2. Set it at job creation from the parsed timeout-minutes. Copy it to matrix instances in workflow_scheduler.
  3. Mirror into the enterprise variables only when the workflow set neither of them.

Tests:

  • Jobs created from workflow YAML, with timeout-minutes: 30 and with none. Check the stored value, job_token_lifetime, and the issued token's exp - iat.
  • A step with GITHUB_ENTERPRISE_TOKEN and GH_TOKEN: no GH_ENTERPRISE_TOKEN is added.

Found in review of #34.

Found in the review of #34. Part of #39.

Activity

  1. fullsend-ai-triage commented on Nov 19, 2026

    @fullsend-ai-triage

    🤖 Finished Triage · ✅ Success · Started 6:01 PM UTC · Completed 6:03 PM UTC

    Commit: 1deccc8 · View workflow run →

    Runtime: claude · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.17

  2. fullsend-ai-triage commented on Nov 19, 2026

    @fullsend-ai-triage

    The problem description and proposed change here are clear, but the code they target is not on the main branch yet. The job-token lifetime logic that reads a job's timeout, and the step environment helper that mirrors the enterprise token variables, are both introduced by the open PR #34. On main, the parsed timeout-minutes is only placed in the job dict in workflow_service.py and is never stored.

    This work therefore has to wait until #34 merges. #34 introduces the code under review rather than fixing this issue, so it is a prerequisite and not an in-flight fix. Once it lands, this issue can be re-triaged and implemented as described.

    Notes for the implementer:

    Blocked by:

  3. added
    ready-to-code
    and removed on Dec 3, 2026
  4. jctanner commented on Dec 3, 2026

    @jctanner
    Collaborator

    Unblocking: the prerequisite PR #34 merged on 2026-11-19. Re-verified against current main: timeout-minutes is parsed into the job dict (workflow_service.py) but there is no workflow_jobs.timeout_minutes column and the job-token lifetime does not consult it — the issue is still fully open.

    Implementer notes from the original triage: base the new Alembic migration on the head at the time (it has moved since); copy the value for matrix instances created in the scheduler; the step environment helper should keep mirroring the enterprise-token variables.

  5. jctanner commented on Dec 3, 2026

    @jctanner
    Collaborator

    /fs-code

  6. fullsend-ai-coder commented on Dec 3, 2026

    @fullsend-ai-coder
    Contributor

    🤖 Finished Code · ✅ Success · Started 2:23 PM UTC · Completed 2:47 PM UTC

    Commit: 0454bac · View workflow run →

    Runtime: claude · Model: opus → claude-opus-5-5 · Effort: high · Cost: $2.35

  7. added a commit that references this issue on Dec 3, 2026
  8. added a commit that references this issue on Dec 3, 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

    ready-to-code

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions