From babaa5711719af071805c0f8c711972b7b302ea2 Mon Sep 17 00:00:00 2001 From: Ramesh Padmanabhaiah <22363102+codeforester@users.noreply.github.com> Date: Fri, 4 Sep 2026 01:26:28 +0530 Subject: [PATCH] fix(gh): report all forced terminal metadata degradation --- lib/bash/gh/lib_gh.sh | 10 +++++----- lib/bash/gh/tests/lib_gh.bats | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/lib/bash/gh/lib_gh.sh b/lib/bash/gh/lib_gh.sh index c3cf20e..363e25a 100644 --- a/lib/bash/gh/lib_gh.sh +++ b/lib/bash/gh/lib_gh.sh @@ -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" \ diff --git a/lib/bash/gh/tests/lib_gh.bats b/lib/bash/gh/tests/lib_gh.bats index 7b88184..5ed05a8 100644 --- a/lib/bash/gh/tests/lib_gh.bats +++ b/lib/bash/gh/tests/lib_gh.bats @@ -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