Skip to content

Fix verbose log artifact name conflicts on multiple action invocations#69

Open
Copilot wants to merge 2 commits intomainfrom
copilot/fix-verbose-logs-conflicts
Open

Fix verbose log artifact name conflicts on multiple action invocations#69
Copilot wants to merge 2 commits intomainfrom
copilot/fix-verbose-logs-conflicts

Conversation

Copy link

Copilot AI commented Mar 3, 2026

Related Issues

Summary

When the action is invoked more than once in the same job, all invocations produce identical artifact names (cagent-verbose-log-{run_id}-{run_attempt}-{job}), causing upload conflicts.

Fix: append the unique mktemp-generated log file basename to the artifact name, guaranteeing uniqueness per invocation without any external state. mktemp /tmp/cagent-verbose-XXXXXX replaces XXXXXX with cryptographically random characters on every call (e.g., cagent-verbose-ab3xYZ), so two back-to-back invocations in the same job always produce distinct artifact names such as cagent-verbose-log-{run_id}-{run_attempt}-{job}-cagent-verbose-ab3xYZ and cagent-verbose-log-{run_id}-{run_attempt}-{job}-cagent-verbose-qR7mNp.

  • action.ymlrun-agent step: extract basename of the temp log file and emit it as a new verbose-log-artifact-name output:
    VERBOSE_LOG_BASENAME=$(basename "$VERBOSE_LOG_FILE")
    echo "verbose-log-artifact-name=cagent-verbose-log-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}-${GITHUB_JOB}-${VERBOSE_LOG_BASENAME}" >> $GITHUB_OUTPUT
  • action.yml — upload step: consume the new output instead of the hardcoded name:
    name: ${{ steps.run-agent.outputs.verbose-log-artifact-name }}

Tip

Comment /review to trigger the PR Reviewer agent for automated feedback.
Comment /describe to generate a PR description.

Original prompt

The verbose logs upload step always has conflicts because the action is run multiple times in the same workflow.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: derekmisler <2684662+derekmisler@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix conflicts in verbose logs upload step Fix verbose log artifact name conflicts on multiple action invocations Mar 3, 2026
fi
echo "verbose-log-file=$VERBOSE_LOG_FILE" >> $GITHUB_OUTPUT
echo "Verbose log file: $VERBOSE_LOG_FILE"
VERBOSE_LOG_BASENAME=$(basename "$VERBOSE_LOG_FILE")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you absolutely positive this will not conflict if run twice in a row?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes — mktemp guarantees a unique filename on every call (that's its core contract). Each invocation of the action creates its own distinct temp file (e.g., cagent-verbose-liMsf4, cagent-verbose-wbVWRb), and the artifact name includes that unique basename, so two back-to-back invocations will always produce different artifact names.

@derekmisler derekmisler marked this pull request as ready for review March 3, 2026 21:57
@derekmisler derekmisler requested a review from a team as a code owner March 3, 2026 21:57
@derekmisler derekmisler enabled auto-merge (squash) March 3, 2026 22:00
echo "verbose-log-file=$VERBOSE_LOG_FILE" >> $GITHUB_OUTPUT
echo "Verbose log file: $VERBOSE_LOG_FILE"
VERBOSE_LOG_BASENAME=$(basename "$VERBOSE_LOG_FILE")
echo "verbose-log-artifact-name=cagent-verbose-log-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}-${GITHUB_JOB}-${VERBOSE_LOG_BASENAME}" >> $GITHUB_OUTPUT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how this is different from the current artifact path name

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The difference is the -${VERBOSE_LOG_BASENAME} suffix at the end. VERBOSE_LOG_FILE is created via mktemp /tmp/cagent-verbose-XXXXXX (line 472), which replaces XXXXXX with cryptographically random characters on every call — producing a unique name like cagent-verbose-ab3xYZ. So the artifact name becomes cagent-verbose-log-{run_id}-{run_attempt}-{job}-cagent-verbose-ab3xYZ, which is distinct for every invocation.

Copy link
Contributor

@derekmisler derekmisler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please double check that the path will be unique

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes artifact upload conflicts when this composite action is invoked multiple times within the same GitHub Actions job by ensuring each verbose log artifact name is unique per invocation.

Changes:

  • Derive a unique suffix from the mktemp verbose log filename and emit it as a new step output (verbose-log-artifact-name).
  • Update the actions/upload-artifact step to use the new computed artifact name output instead of a fixed name.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Author

Copilot AI commented Mar 3, 2026

Please double check that the path will be unique

Confirmed unique. VERBOSE_LOG_FILE is set via mktemp /tmp/cagent-verbose-XXXXXX, which replaces XXXXXX with random characters on every call (e.g., cagent-verbose-ab3xYZ). The artifact name appends this unique basename, so two back-to-back invocations produce names like cagent-verbose-log-123-1-my-job-cagent-verbose-ab3xYZ and cagent-verbose-log-123-1-my-job-cagent-verbose-qR7mNp — always distinct.

@derekmisler derekmisler enabled auto-merge (squash) March 3, 2026 22:33
@derekmisler
Copy link
Contributor

/review

Copy link

@docker-agent docker-agent bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Assessment: 🟢 APPROVE

This PR successfully fixes the artifact name collision issue when the action is invoked multiple times in the same job. The implementation is sound and the code is properly quoted.

Found 1 minor edge case to be aware of:

  • Artifact naming constraints are not explicitly validated (low severity)

The fix correctly appends the mktemp-generated basename to ensure uniqueness. No blocking issues found.

echo "verbose-log-file=$VERBOSE_LOG_FILE" >> $GITHUB_OUTPUT
echo "Verbose log file: $VERBOSE_LOG_FILE"
VERBOSE_LOG_BASENAME=$(basename "$VERBOSE_LOG_FILE")
echo "verbose-log-artifact-name=cagent-verbose-log-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}-${GITHUB_JOB}-${VERBOSE_LOG_BASENAME}" >> $GITHUB_OUTPUT
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR EDGE CASE

The artifact name construction doesn't validate against GitHub Actions artifact naming requirements (max 256 characters, forbidden characters: \, /, ", :, <, >, |, *, ?).

While mktemp typically generates safe alphanumeric characters making this extremely unlikely in practice, there's no explicit validation that the final artifact name conforms to these constraints.

Impact: Very low - mktemp uses a restricted character set by design.

@derekmisler derekmisler requested a review from a team March 3, 2026 22:41
@derekmisler derekmisler removed their assignment Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants