Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/bash/gh/lib_gh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1649,22 +1649,22 @@ __base_bash_libs_gh_api_with_retry_impl__() {
esac

__base_bash_libs_gh_api_attempt_argv=("$@")
__base_bash_libs_gh_api_forced_terminal_env__ __base_bash_libs_gh_api_forced_terminal_env
if ((__base_bash_libs_gh_api_retry_authorized && !__base_bash_libs_gh_api_include && !__base_bash_libs_gh_api_ambiguous)); then
__base_bash_libs_gh_api_forced_terminal_env__ __base_bash_libs_gh_api_forced_terminal_env
__base_bash_libs_gh_api_can_inject_include__ __base_bash_libs_gh_api_can_inject "$@"
if ((__base_bash_libs_gh_api_can_inject)); then
__base_bash_libs_gh_api_injected_include=1
__base_bash_libs_gh_api_include=1
__base_bash_libs_gh_api_attempt_argv=(--include "$@")
elif [[ -n "$__base_bash_libs_gh_api_forced_terminal_env" ]]; then
base_std_log_warn -l base_bash_libs.gh \
"base_gh_api_with_retry: $__base_bash_libs_gh_api_forced_terminal_env is set; structured retry metadata is unavailable."
fi
fi
__base_bash_libs_gh_api_unstructured_transport_is_safe__ __base_bash_libs_gh_api_transport_syntax_safe "$@"
((__base_bash_libs_gh_api_ambiguous == 0)) || __base_bash_libs_gh_api_transport_syntax_safe=0
[[ -z "${GH_FORCE_TTY-}${CLICOLOR_FORCE-}${FORCE_COLOR-}" ]] ||
if [[ -n "$__base_bash_libs_gh_api_forced_terminal_env" ]]; then
__base_bash_libs_gh_api_structured_metadata=0
base_std_log_warn -l base_bash_libs.gh \
"base_gh_api_with_retry: $__base_bash_libs_gh_api_forced_terminal_env is set; structured retry metadata is unavailable."
fi

if ((__base_bash_libs_gh_api_sensitive)); then
if ! __base_bash_libs_std_render_command_display__ __base_bash_libs_gh_api_display 1 "$__base_bash_libs_gh_api_safe_display" \
Expand Down
22 changes: 22 additions & 0 deletions lib/bash/gh/tests/lib_gh.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,28 @@ EOF
[[ "$output" == *"CLICOLOR_FORCE is set; structured retry metadata is unavailable"* ]]
}

@test "base_gh_api_with_retry reports forced terminal metadata degradation for explicit include and mutations" {
install_gh_api_retry_fixture
TEST_GH_API_SUCCESS_AFTER=99
TEST_GH_API_FAILURE_STDOUT=$'HTTP/2.0 503 Service Unavailable\r\nRetry-After: 0\r\n\r\nbody\n'
base_std_set_log_level DEBUG
export CLICOLOR_FORCE=1

capture_command base_gh_api_with_retry repos/owner/repo --include
[ "$status" -eq 1 ]
[ "$(gh_api_retry_observed attempts)" -eq 1 ]
[[ "$output" == *"CLICOLOR_FORCE is set; structured retry metadata is unavailable"* ]]

install_gh_api_retry_fixture
TEST_GH_API_SUCCESS_AFTER=99
TEST_GH_API_FAILURE_STDOUT=$'HTTP/2.0 503 Service Unavailable\r\nRetry-After: 0\r\n\r\nbody\n'
capture_command base_gh_api_with_retry repos/owner/repo --method POST
[ "$status" -eq 1 ]
[ "$(gh_api_retry_observed attempts)" -eq 1 ]
[[ "$output" == *"CLICOLOR_FORCE is set; structured retry metadata is unavailable"* ]]
unset CLICOLOR_FORCE
}

@test "base_gh_api_with_retry does not retry auth cancellation certificate or gh usage failures" {
local failure_status failure_text

Expand Down
Loading