Skip to content

Differentiate HTTP status codes in branch existence checks - #459

Merged
mallendem merged 7 commits into
mainfrom
copilot/improve-error-handling
Apr 10, 2026
Merged

mallendem merged 7 commits into
mainfrom
copilot/improve-error-handling

Conversation

Copilot AI commented Feb 18, 2026 •

Copy link
Copy Markdown
Contributor

The elastic/active-branches action reports "branch does not exist" for all non-200 HTTP responses when checking GitHub API, conflating 404 (not found) with 401 (auth failure), 403 (forbidden), 500+ (server errors), etc.

Changes

elastic/active-branches/script.py

  • Added specific error messages for HTTP status codes:
    • 404: Branch does not exist
    • 401: Authentication failed, check GITHUB_TOKEN
    • 403: Access forbidden, check permissions
    • 500+: Server error, GitHub API issues
    • Other: Unexpected error with status code

.gitignore

  • Excluded Python cache artifacts

Example

Before:

Branch 8.15 does not exist in the repository  # Could be 404, 403, 500...

After:

Access forbidden for branch 8.15 (HTTP 403). Check permissions.

The functional behavior remains unchanged—non-200 responses still exclude branches from results.

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:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh gh pr view 459 --json statusCheckRollup --local de/node/bin/rust--64 credential.helpeas (http block)
  • https://api.github.com/repos/elastic/oblt-actions/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list x64/pkg/include -c x64/src/runtime/cgo (http 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>Improve error handling for elastic/oblt-actions/updatecli/run@v1</issue_title>
<issue_description>The action elastic/oblt-actions/updatecli/run@v1 currently has a catch-all non 200 codes as "branch does not exists". This is not always the case and is confusing.

We ned to branch the different http codes (400, 500...) and output a clearer message in a non-200 error.

The intent is to increase the resiliency in the future, but for now we should produce a better error and debugging experience. </issue_description>

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


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: mallendem <105422197+mallendem@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve error handling for non-200 HTTP codes Differentiate HTTP status codes in branch existence checks Feb 18, 2026
Copilot AI requested a review from mallendem February 18, 2026 15:56
@mallendem mallendem added the changelog:enhancement When you enhance an existing feature label Mar 10, 2026
@mallendem
mallendem marked this pull request as ready for review March 10, 2026 10:23
@mallendem
mallendem requested a review from a team as a code owner March 10, 2026 10:23
Copilot AI review requested due to automatic review settings March 10, 2026 10:23
@mallendem
mallendem enabled auto-merge March 10, 2026 10:23
@mallendem
mallendem requested a review from a team March 10, 2026 10:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the elastic/active-branches composite action’s branch existence filtering by providing differentiated, more actionable log messages for non-200 GitHub API responses, instead of treating all failures as “branch does not exist”.

Changes:

  • Added status-code-specific logging for branch existence checks (401/403/404/5xx/other).
  • Kept functional filtering behavior the same (only HTTP 200 branches are retained).
  • Updated .gitignore to exclude Python bytecode/cache artifacts.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 2 comments.

File Description
elastic/active-branches/script.py Adds differentiated messages for non-200 GitHub API responses during branch existence checks.
.gitignore Ignores Python __pycache__ and .pyc/.pyo artifacts.

Comment thread elastic/active-branches/script.py Outdated
Comment thread elastic/active-branches/script.py Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@mallendem
mallendem requested a review from v1v March 10, 2026 16:43

@v1v v1v left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thanks

@mallendem
mallendem added this pull request to the merge queue Mar 10, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 10, 2026
@mallendem
mallendem added this pull request to the merge queue Mar 10, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 10, 2026
@mallendem
mallendem added this pull request to the merge queue Mar 10, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 10, 2026
Comment thread elastic/active-branches/script.py
@mallendem
mallendem added this pull request to the merge queue Mar 11, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 11, 2026
Copilot AI review requested due to automatic review settings April 10, 2026 08:28

@fr4nc1sc0-r4m0n fr4nc1sc0-r4m0n left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment on lines +56 to +61
f"Access forbidden for branch {branch} (HTTP 403)."
f"This may be due to rate limiting or missing permissions."
)
if rate_limit_remaining is not None or rate_limit_reset is not None:
print(
f"X-RateLimit-Remaining={rate_limit_remaining}"

Copilot AI Apr 10, 2026

Copy link

Choose a reason for hiding this comment

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

In the HTTP 403 branch, the two adjacent f-strings in the print(...) call will be implicitly concatenated without any separator, resulting in output like ...(HTTP 403).This may be... (missing space/newline). Add an explicit space/newline (or pass multiple args to print) so the message is readable.

Suggested change
f"Access forbidden for branch {branch} (HTTP 403)."
f"This may be due to rate limiting or missing permissions."
)
if rate_limit_remaining is not None or rate_limit_reset is not None:
print(
f"X-RateLimit-Remaining={rate_limit_remaining}"
f"Access forbidden for branch {branch} (HTTP 403). "
f"This may be due to rate limiting or missing permissions."
)
if rate_limit_remaining is not None or rate_limit_reset is not None:
print(
f"X-RateLimit-Remaining={rate_limit_remaining} "

Copilot uses AI. Check for mistakes.
Comment on lines +59 to +63
if rate_limit_remaining is not None or rate_limit_reset is not None:
print(
f"X-RateLimit-Remaining={rate_limit_remaining}"
f"X-RateLimit-Reset={rate_limit_reset}"
)

Copilot AI Apr 10, 2026

Copy link

Choose a reason for hiding this comment

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

The rate-limit debug print(...) also uses adjacent f-strings, so the values will run together (e.g., X-RateLimit-Remaining=0X-RateLimit-Reset=...). Additionally, if only one of the headers is present the other will print as None. Consider printing only the headers that are present and separating them clearly (space/comma/newline).

Suggested change
if rate_limit_remaining is not None or rate_limit_reset is not None:
print(
f"X-RateLimit-Remaining={rate_limit_remaining}"
f"X-RateLimit-Reset={rate_limit_reset}"
)
rate_limit_headers = []
if rate_limit_remaining is not None:
rate_limit_headers.append(
f"X-RateLimit-Remaining={rate_limit_remaining}"
)
if rate_limit_reset is not None:
rate_limit_headers.append(f"X-RateLimit-Reset={rate_limit_reset}")
if rate_limit_headers:
print(", ".join(rate_limit_headers))

Copilot uses AI. Check for mistakes.
Merged via the queue into main with commit b057aeb Apr 10, 2026
27 checks passed
@mallendem
mallendem deleted the copilot/improve-error-handling branch April 10, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:enhancement When you enhance an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve error handling for elastic/oblt-actions/updatecli/run@v1

5 participants