refactor: simplify seat probe diagnostics in copilot-report#50
Merged
locus313 merged 1 commit intoJul 14, 2026
Merged
Conversation
Remove dead 403 branch (GitHub returns 404, not 403, on billing
endpoints when manage_billing:enterprise scope is absent — documented
in the code itself). Flatten the nested 404 scope-check into a
single if/else, eliminating repeated error messages and reducing the
block by ~22 lines while preserving all actionable guidance.
Also initialise all declare -A statements with =() to fix empty-array
expansion under bash 5.3, and add a guard for the empty-string element
that bash 5.3 emits when iterating ${!assoc[@]} on an empty array.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Ponytail audit cleanup of the zero-seat probe block added to
github-copilot-report.sh. The block was correct in purpose but had two unnecessary complexity hotspots.Changes
<domain>/github-<name>/github-<name>.shlib/github-common.shreporting/github-copilot-report/github-copilot-report.shRemoved dead 403 branch — the code's own comment documented that GitHub returns 404 (not 403) on billing endpoints when
manage_billing:enterprisescope is absent. The 403 case would never fire.Flattened nested 404 scope-check — replaced a 3-level nested if/else (22 lines, repeated error text) with a single if/else (8 lines) that preserves all actionable guidance.
Initialised
declare -Awith=()— fixes empty-array expansion under bash 5.3 for_GRAPH_CACHE,USER_CREDITS_USED,USER_MODEL_CREDITS,_ALL_MODELS_SET,DEPT_USERS,DEPT_CREDITS.Added empty-string guard in department loop — bash 5.3 emits a single empty-string element when iterating
${!assoc[@]}on an empty associative array; the[[ -z "$dept" ]] && continueguard prevents a blank row in the summary table.Net diff: ~22 lines removed.
How to test
Expected: same output as before for enterprises with seats. For enterprises with 0 seats, the 404 error message now points directly to the missing scope or wrong slug without repeating itself.
Checklist
set -euo pipefailis the first executable line after the# ===headerlib/github-common.shviaSCRIPT_DIRrequire_env_varvalidate_github_token(orvalidate_tokenfor secondary tokens)validate_slugsleepadded between repo-level operations to respect rate limitsshellcheck --severity=warning --exclude=SC2034,SC1091 --shell=bash)