Skip to content

Validate Jira base URL before API calls#506

Merged
jirhiker merged 1 commit intostagingfrom
jira-automation
Feb 13, 2026
Merged

Validate Jira base URL before API calls#506
jirhiker merged 1 commit intostagingfrom
jira-automation

Conversation

@jirhiker
Copy link
Copy Markdown
Member

Why

This PR addresses the following problem / context:

  • Use bullet points here

How

Implementation summary - the following was changed / added / removed:

  • Use bullet points here

Notes

Any special considerations, workarounds, or follow-up work to note?

  • Use bullet points here

Copilot AI review requested due to automatic review settings February 13, 2026 16:57
@jirhiker jirhiker merged commit 3c0db67 into staging Feb 13, 2026
8 checks passed
Copy link
Copy Markdown
Contributor

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

This pull request adds validation for Jira configuration variables before making API calls in the GitHub Actions workflow. The changes improve error handling by checking required environment variables and validating the JIRA_BASE_URL format before attempting to interact with the Jira API.

Changes:

  • Added validation to check that required Jira configuration variables (JIRA_BASE_URL, JIRA_EMAIL, JIRA_API_TOKEN, JIRA_KEY) are set
  • Added URL scheme validation to ensure JIRA_BASE_URL includes a proper scheme (http:// or https://)
  • Added trailing slash normalization for JIRA_BASE_URL to ensure consistent URL formatting

;;
esac

JIRA_BASE_URL="${JIRA_BASE_URL%/}"
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

After normalizing the trailing slash on line 399, the JIRA_BASE_URL is used on line 427 to construct the API endpoint. However, unlike the "Fetch Jira issue JSON" step (line 120), this step doesn't store the normalized URL in an intermediate variable (ISSUE_URL). While the current implementation works, consider adding an ISSUE_URL variable here as well for consistency with the first step and to make the curl command clearer.

Copilot uses AI. Check for mistakes.
Comment on lines +111 to +117
case "$JIRA_BASE_URL" in
http://*|https://*) ;;
*)
echo "JIRA_BASE_URL must include scheme and host (e.g., https://your-domain.atlassian.net)"
exit 1
;;
esac
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The URL scheme validation only checks if JIRA_BASE_URL starts with "http://" or "https://", but doesn't verify that there's actually a hostname after the scheme. This would allow invalid URLs like "http://" or "https://" to pass validation. Consider adding a more robust check that ensures the URL contains both a scheme and a hostname, for example by checking if the URL contains at least one character after the scheme and "://".

Copilot uses AI. Check for mistakes.
exit 1
;;
esac

Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The URL scheme validation only checks if JIRA_BASE_URL starts with "http://" or "https://", but doesn't verify that there's actually a hostname after the scheme. This would allow invalid URLs like "http://" or "https://" to pass validation. Consider adding a more robust check that ensures the URL contains both a scheme and a hostname, for example by checking if the URL contains at least one character after the scheme and "://".

Suggested change
host_and_rest="${JIRA_BASE_URL#*://}"
jira_host="${host_and_rest%%/*}"
if [ -z "$jira_host" ]; then
echo "JIRA_BASE_URL must include scheme and host (e.g., https://your-domain.atlassian.net)"
exit 1
fi

Copilot uses AI. Check for mistakes.
Comment on lines +104 to +119
for v in JIRA_BASE_URL JIRA_EMAIL JIRA_API_TOKEN JIRA_KEY; do
if [ -z "${!v:-}" ]; then
echo "Missing required Jira configuration: $v"
exit 1
fi
done

case "$JIRA_BASE_URL" in
http://*|https://*) ;;
*)
echo "JIRA_BASE_URL must include scheme and host (e.g., https://your-domain.atlassian.net)"
exit 1
;;
esac

JIRA_BASE_URL="${JIRA_BASE_URL%/}"
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The validation logic for Jira configuration is duplicated between this step and the "Comment back on Jira with PR link" step (lines 384-400). Consider extracting this validation into a reusable composite action or a shared shell script to avoid duplication and ensure consistency in validation logic across both steps.

Suggested change
for v in JIRA_BASE_URL JIRA_EMAIL JIRA_API_TOKEN JIRA_KEY; do
if [ -z "${!v:-}" ]; then
echo "Missing required Jira configuration: $v"
exit 1
fi
done
case "$JIRA_BASE_URL" in
http://*|https://*) ;;
*)
echo "JIRA_BASE_URL must include scheme and host (e.g., https://your-domain.atlassian.net)"
exit 1
;;
esac
JIRA_BASE_URL="${JIRA_BASE_URL%/}"
jira_validate_jira_config() {
for v in JIRA_BASE_URL JIRA_EMAIL JIRA_API_TOKEN JIRA_KEY; do
if [ -z "${!v:-}" ]; then
echo "Missing required Jira configuration: $v"
exit 1
fi
done
case "$JIRA_BASE_URL" in
http://*|https://*) ;;
*)
echo "JIRA_BASE_URL must include scheme and host (e.g., https://your-domain.atlassian.net)"
exit 1
;;
esac
JIRA_BASE_URL="${JIRA_BASE_URL%/}"
}
jira_validate_jira_config

Copilot uses AI. Check for mistakes.
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.

2 participants