return-dispatch
return-dispatch copied to clipboard
Exhausted searching IDs in known runs
Hello,
I am also facing this issue where it's not able to parse the run ID from the fetched steps. . see the logs below:
Run codex-/return-dispatch@feat/improve_retry_strategy
Fetching Workflow ID for integration-tests.yaml...
Fetched Workflow ID: 120552602
Successfully dispatched workflow:
Repository: ***
Branch: main
Workflow ID: integration-tests.yaml
Workflow Inputs: {"commit_hash":"1495d0634a0e195b19a9908e53e99effbae7fab8"}
Distinct ID: efc563f4-5c6d-4a77-9ec6-f18d3288ed85
Attempt to extract run ID from steps...
Exhausted searching IDs in known runs, attempt 1...
is it because the fetched workflow run doesn't have the branch value of "main"? when I hit the endpoint that specific workflow run returns the head_branch, I am wondering if how it's parsing. would you be able to give some advice what I can do resolve this issue?
Thank you in advance.
looking into the code it seems like it's printing the value that must be provided in the config.
I have defined my workflow step like this
- name: Dispatch Event to Processor Repo
uses: codex-/return-dispatch@feat/improve_retry_strategy
id: return_dispatch
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
repo: ***
owner: ***
ref: main
workflow: integration-tests.yaml
workflow_inputs: '{"commit_hash": "${{ github.sha }}"}'
function getBranchNameFromRef(ref: string): string | undefined {
const refItems = ref.split(/\/?refs\/heads\//);
if (refItems.length > 1 && (refItems[1]?.length ?? 0) > 0) {
return refItems[1];
}
}
any chance this code has a potential issue?
function getBranchNameFromRef(ref: string): string | undefined {
const refItems = ref.split(/\/?refs\/heads\//);
if (refItems.length > 1 && (refItems[1]?.length ?? 0) > 0) {
return refItems[1];
}
}
function isTagRef(ref: string): boolean {
return new RegExp(/\/?refs\/tags\//).test(ref);
}
export function getBranchName(ref: string): string | undefined {
let branchName: string | undefined = undefined;
if (!isTagRef(ref)) {
/**
* The listRepoWorkflows request only accepts a branch name and not a ref (for some reason).
*
* Attempt to filter the branch name specifically and use that.
*/
const branch = getBranchNameFromRef(ref);
if (branch) {
branchName = branch;
core.debug(`getWorkflowRunIds: Filtered branch name: ${ref}`);
} else {
core.debug(
`failed to get branch for ref: ${ref}, please raise an issue with this git ref.`,
);
}
} else {
core.debug(`Unable to filter branch, unsupported ref: ${ref}`);
}
return branchName;
}
looks like if i pass "main", it's going to return undefined.
okay also the core issue is that it's looking for a distinct ID from steps fetched? and if I don't pass in distinct Id, it seems like using uuid(), and i don't think idRegex against the runId would never match? how is this supposed to work? Could you explain if I missed something from the way I set up the Step
I've reworked a tonne of these particular pieces of logic and added extensive testing for them all in V2 which is due to release soon
If you find this is still an issue please let me know and I'll re-open this
Hey, I'm still seeing this issue. I'm trying to dispatch an action in the same repo.
Here's the dispatching action aws_cdk_deploy_on_cdk_update.yml:
# On pull requests that update datadog-cdk-constructs-v2 version, deploy the stacks to test the changes
name: AWS deploy to test latest Datadog CDK
permissions:
contents: read # needed to checkout the code
actions: write # needed to trigger the aws_cdk_deploy workflow
on:
push:
branches:
- 'github-actions/update-dd-cdk-version'
- 'yiming.luo/auto-update-cdk-version-6' # for testing
jobs:
deploy:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GH_ACTION_PAT }}
steps:
- name: Trigger AWS deploy Workflow
uses: codex-/return-dispatch@2410062d00e50fbdc50dd9065a4e5f673e2455d3 # v2.0.3
id: return_dispatch
with:
token: ${{ secrets.GH_ACTION_PAT }}
repo: serverless-self-monitoring
owner: DataDog
ref: refs/heads/yiming.luo/auto-update-cdk-version-6
workflow: aws_cdk_deploy.yml
workflow_inputs: '{ "STACK_PREFIX": "cdkupdate" }'
workflow_timeout_seconds: 1800
- ...
Here's the receiving action aws_cdk_deploy.yml:
name: AWS deploy
on:
workflow_dispatch:
inputs:
distinct_id:
description: A dummy variable for compatability with GitHub Action codex-/return-dispatch, so this workflow can be triggered by aws_cdk_deploy_on_cdk_update.yml
required: false
...
env:
...
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
When I push to yiming.luo/auto-update-cdk-version-6 branch, the dispatching action is run:
Run codex-/return-dispatch@2410062d00e50fbdc50dd9065a4e5f673e2455d3
with:
token: ***
repo: serverless-self-monitoring
owner: DataDog
ref: refs/heads/yiming.luo/auto-update-cdk-version-6
workflow: aws_cdk_deploy.yml
workflow_inputs: { "STACK_PREFIX": "cdkupdate" }
workflow_timeout_seconds: 1800
env:
GH_TOKEN: ***
Fetching Workflow ID for aws_cdk_deploy.yml...
Fetched Workflow ID:
Repository: DataDog/serverless-self-monitoring
Workflow ID: '54830463'
Input Filename: 'aws_cdk_deploy.yml'
Sanitised Filename: 'aws_cdk_deploy\.yml'
URL: https://github.com/DataDog/serverless-self-monitoring/blob/main/.github/workflows/aws_cdk_deploy.yml
Fetched Workflow ID: 54830463
Successfully dispatched workflow:
Repository: DataDog/serverless-self-monitoring
Branch: refs/heads/yiming.luo/auto-update-cdk-version-6
Workflow: aws_cdk_deploy.yml
Workflow Inputs: {"STACK_PREFIX":"cdkupdate"}
Distinct ID: 57c63979-19c7-41c4-8322-6b266ce3[16](https://github.com/DataDog/serverless-self-monitoring/actions/runs/12360643868/job/34498341289#step:2:17)3a
Attempt to extract branch name from ref...
Branch found for 'refs/heads/yiming.luo/auto-update-cdk-version-6': yiming.luo/auto-update-cdk-version-6
Attempting to identify run ID from steps...
Exhausted searching IDs in known runs, attempt 1...
Exhausted searching IDs in known runs, attempt 2...
Exhausted searching IDs in known runs, attempt 3...
Exhausted searching IDs in known runs, attempt 4...
Exhausted searching IDs in known runs, attempt 5...
Exhausted searching IDs in known runs, attempt 6...
For the PAT, I've tried both:
- fine-grained token with:
- actions: read and write
- metadata: read-only
- classic token with:
- all of "repo" scope
- workflow
Do you have any idea what's wrong? Thanks!
Ah damn, sorry you're having trouble, let's work it out 🚀
For aws_cdk_deploy.yml is there a step like:
steps:
- name: echo distinct ID ${{ github.event.inputs.distinct_id }}
run: echo ${{ github.event.inputs.distinct_id }}
Without it the action cannot identify as it uses the step names to find the right run
I don't have such a step. Will try!
It worked! Thank you for your quick response!
Awesome, glad it's working, no problem at all :)
Let me know if you run into any more trouble, closing for now