Repository navigation
fix(#70): job token uses the job's timeout; keep own enterprise token #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
fullsend-ai-coder
wants to merge
2
commits into
main
Choose a base branch
from
agent/70-job-token-timeout-minutes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| """Keep a job's timeout-minutes. | ||
|
|
||
| The upstream runner's job token lives for the job's timeout plus a margin, | ||
| but the parsed timeout-minutes was never stored, so every token was issued | ||
| for the 360-minute default: longer than a short job may run, and expiring | ||
| before a long one ends. NULL means the default; existing jobs keep it. | ||
|
|
||
| Revision ID: 0022_workflow_job_timeout_minutes | ||
| Revises: 0021_runner_registration_broker | ||
| Create Date: 2026-12-03 | ||
| """ | ||
|
|
||
| import sqlalchemy as sa | ||
| from alembic import op | ||
| from sqlalchemy import inspect | ||
|
|
||
| revision = "0022_workflow_job_timeout_minutes" | ||
| down_revision = "0021_runner_registration_broker" | ||
| branch_labels = None | ||
| depends_on = None | ||
|
|
||
| _TABLE = "workflow_jobs" | ||
| _COLUMN = "timeout_minutes" | ||
|
|
||
|
|
||
| def upgrade() -> None: | ||
| bind = op.get_bind() | ||
| inspector = inspect(bind) | ||
| if _TABLE not in inspector.get_table_names(): | ||
| return | ||
| if _COLUMN in {column["name"] for column in inspector.get_columns(_TABLE)}: | ||
| return | ||
| op.add_column(_TABLE, sa.Column(_COLUMN, sa.Integer(), nullable=True)) | ||
|
|
||
|
|
||
| def downgrade() -> None: | ||
| bind = op.get_bind() | ||
| inspector = inspect(bind) | ||
| if _TABLE not in inspector.get_table_names(): | ||
| return | ||
| if _COLUMN not in {column["name"] for column in inspector.get_columns(_TABLE)}: | ||
| return | ||
| op.drop_column(_TABLE, _COLUMN) |
39 changes: 39 additions & 0 deletions
39
docs/bugs/fixed/job-token-ignores-the-jobs-timeout-minutes.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # Bug: the upstream-runner job token ignores the job's timeout-minutes | ||
|
|
||
| Status: fixed 2026-12-03 (issue #70). | ||
|
|
||
| ## Summary | ||
|
|
||
| - `job_token_lifetime` issues the job token for the job's timeout plus 5 | ||
| minutes, capped at 24 hours. It reads `timeout_minutes` from the job, but | ||
| `WorkflowJob` had no such column. The parsed `timeout-minutes` was never | ||
| stored, so every token lived 365 minutes. That is longer than a | ||
| `timeout-minutes: 30` job may run. It also expires before a job with more | ||
| than 360 minutes ends, and that job's completion report then gets 401. | ||
| - `_with_gh_enterprise_token` filled each enterprise variable on its own. A | ||
| step that set only `GITHUB_ENTERPRISE_TOKEN` still got | ||
| `GH_ENTERPRISE_TOKEN` mirrored from `GH_TOKEN`. `gh` reads | ||
| `GH_ENTERPRISE_TOKEN` first, so it used the mirrored token, not the one | ||
| the workflow chose. | ||
|
|
||
| ## Fix | ||
|
|
||
| - New nullable column `workflow_jobs.timeout_minutes` (migration 0022). | ||
| NULL means the default (360). | ||
| - Job creation stores the parsed `timeout-minutes` when it is a positive | ||
| number. An expression is not evaluated and gets the default. Instances of | ||
| a dynamic matrix copy it in `workflow_scheduler`. | ||
| - The token is mirrored into the enterprise variables only when the step's | ||
| environment sets neither of them. | ||
|
|
||
| ## Evidence | ||
|
|
||
| - `tests/actions/test_runner_job_outputs.py`: jobs created with | ||
| `timeout-minutes: 30` and with none. The test checks the stored value, | ||
| `job_token_lifetime`, and the issued token's `exp - iat`. | ||
| - `tests/actions/test_dynamic_matrix.py`: every matrix instance keeps the | ||
| timeout. | ||
| - `tests/actions/test_runner_gh_host.py`: a step with | ||
| `GITHUB_ENTERPRISE_TOKEN` and `GH_TOKEN` gets no `GH_ENTERPRISE_TOKEN`. | ||
| - `tests/test_database_migrations.py`: 0022 adds the column to a database at | ||
| 0021 and keeps existing jobs, which get NULL. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.