Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 7, 2025

Problem

When link-commits-to-pull-request is set to true, the action attempts to link work items to pull requests using Azure DevOps APIs. However, if the required azure-devops-organization or azure-devops-token inputs are not provided, the action would proceed to call the Node.js script and fail with a cryptic error later in the process.

The code had a TODO comment indicating this validation was needed:

# TODO: check to see if org/pat are set

Solution

Added validation checks before attempting to link work items that verify both Azure DevOps configuration values are set. The validation:

  1. Checks each input separately - First validates azure-devops-organization, then azure-devops-token
  2. Provides specific error messages - Each check has a clear error message indicating exactly which configuration is missing:
    • "Azure DevOps organization is required when link-commits-to-pull-request is true"
    • "Azure DevOps token is required when link-commits-to-pull-request is true"
  3. Fails early - The action exits immediately (exit 1) with a GitHub Actions error annotation before attempting API calls

Example

If a user configures the action with link-commits-to-pull-request: true but forgets to set the organization:

Before: The action would fail later with a cryptic error about Azure DevOps API calls failing

After: The action fails immediately with:

::error title=Missing Azure DevOps Configuration::Azure DevOps organization is required when link-commits-to-pull-request is true

Testing

Added comprehensive test coverage in __tests__/action.test.sh:

  • ✅ Validation passes when both org and PAT are set
  • ✅ Validation fails when org is empty
  • ✅ Validation fails when PAT is empty
  • ✅ Validation fails when both are empty

All 29 bash tests and 3 JavaScript tests pass with no regressions.

Fixes the TODO comment and improves user experience by providing clear, actionable error messages early in the workflow execution.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dev.azure.com
    • Triggering command: node /home/REDACTED/work/azdo_commit_message_validator/azdo_commit_message_validator/node_modules/.bin/jest (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>If link-commits-to-pull-request is true, verify Azure DevOps Org and PAT are set</issue_title>
<issue_description>Verify that both are not empty

if ${{ inputs.link-commits-to-pull-request }}; then
  # make the call to main.js to do the linking
  # TODO: check to see if org/pat are set
  echo "Attempting to link work item ${WORKITEM} to pull request ${PULL_NUMBER}..."
  REPO_TOKEN=${{ inputs.github-token }} AZURE_DEVOPS_ORG=${{ inputs.azure-devops-organization }} AZURE_DEVOPS_PAT=${{ inputs.azure-devops-token }} WORKITEMID=$WORKITEM PULLREQUESTID=${{ github.event.number }} REPO=${{ github.repository }} node $main
  echo "...PR linked to work item"
fi
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>

Fixes #74

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] Verify Azure DevOps Org and PAT are set when linking commits Verify Azure DevOps Org and PAT are set when link-commits-to-pull-request is true Oct 7, 2025
@Copilot Copilot AI requested a review from joshjohanning October 7, 2025 16:47
Copilot finished work on behalf of joshjohanning October 7, 2025 16:47
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.

If link-commits-to-pull-request is true, verify Azure DevOps Org and PAT are set

2 participants