Skip to content

Commit 1d48d13

Browse files
authored
feat(validate-inputs): downgrade validation failures to warnings (#300)
Emit ::warning annotations, log to stderr, and append to step summary without failing the step. Replace error exits with warnings across all validation branches. We can move this to errors in future releases, but don't want to break downstream users once we cut a release.
1 parent af6cb68 commit 1d48d13

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

scripts/validate-inputs.sh

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
#!/bin/bash
22
set -euo pipefail
33

4-
# Emit a clear error in three places:
4+
# Emit a clear warning in three places without failing the step:
55
# - STDERR (visible in step logs)
6-
# - GitHub annotation with a title (more visible in Checks)
7-
# - Step summary (always shown in the job summary)
8-
error() {
6+
# - GitHub warning annotation with a title (visible in Checks)
7+
# - Step summary (shown in the job summary)
8+
warn() {
99
local msg="$1"
10-
echo "ERROR: ${msg}" >&2
11-
echo "::error title=Input validation failed::${msg}"
10+
echo "WARNING: ${msg}" >&2
11+
echo "::warning title=Input validation::${msg}"
1212
if [[ -n "${GITHUB_STEP_SUMMARY:-}" ]]; then
1313
{
14-
echo "### Input validation failed"
14+
echo "### Input validation warnings"
1515
echo
1616
echo "- ${msg}"
1717
} >> "${GITHUB_STEP_SUMMARY}"
1818
fi
19-
exit 1
2019
}
2120

2221
# Auth inputs (as boolean presence flags)
@@ -37,39 +36,39 @@ if [[ "${google_api_key_present}" == "true" ]]; then ((auth_methods++)); fi
3736
if [[ "${gcp_workload_identity_provider_present}" == "true" ]]; then ((auth_methods++)); fi
3837

3938
if [[ ${auth_methods} -eq 0 ]]; then
40-
error "No authentication method provided. Please provide one of 'gemini_api_key', 'google_api_key', or 'gcp_workload_identity_provider'."
39+
warn "No authentication method provided. Please provide one of 'gemini_api_key', 'google_api_key', or 'gcp_workload_identity_provider'."
4140
fi
4241

4342
if [[ ${auth_methods} -gt 1 ]]; then
44-
error "Multiple authentication methods provided. Please use only one of 'gemini_api_key', 'google_api_key', or 'gcp_workload_identity_provider'."
43+
warn "Multiple authentication methods provided. Please use only one of 'gemini_api_key', 'google_api_key', or 'gcp_workload_identity_provider'."
4544
fi
4645

4746
# WIF validation
4847
if [[ "${gcp_workload_identity_provider_present}" == "true" ]]; then
4948
if [[ "${gcp_project_id_present}" != "true" || "${gcp_service_account_present}" != "true" ]]; then
50-
error "When using Workload Identity Federation ('gcp_workload_identity_provider'), you must also provide 'gcp_project_id' and 'gcp_service_account'."
49+
warn "When using Workload Identity Federation ('gcp_workload_identity_provider'), you must also provide 'gcp_project_id' and 'gcp_service_account'."
5150
fi
5251
if [[ "${use_vertex_ai}" != "true" && "${use_gemini_code_assist}" != "true" ]]; then
53-
error "When using Workload Identity Federation, you must set either 'use_vertex_ai' or 'use_gemini_code_assist' to 'true'. Both are set to 'false', please choose one."
52+
warn "When using Workload Identity Federation, you must set either 'use_vertex_ai' or 'use_gemini_code_assist' to 'true'. Both are set to 'false', please choose one."
5453
fi
5554
if [[ "${use_vertex_ai}" == "true" && "${use_gemini_code_assist}" == "true" ]]; then
56-
error "When using Workload Identity Federation, 'use_vertex_ai' and 'use_gemini_code_assist' cannot both be 'true'. Both are set to 'true', please choose one."
55+
warn "When using Workload Identity Federation, 'use_vertex_ai' and 'use_gemini_code_assist' cannot both be 'true'. Both are set to 'true', please choose one."
5756
fi
5857
fi
5958

6059
# Vertex AI API Key validation
6160
if [[ "${google_api_key_present}" == "true" ]]; then
6261
if [[ "${use_vertex_ai}" != "true" ]]; then
63-
error "When using 'google_api_key', you must set 'use_vertex_ai' to 'true'."
62+
warn "When using 'google_api_key', you must set 'use_vertex_ai' to 'true'."
6463
fi
6564
if [[ "${use_gemini_code_assist}" == "true" ]]; then
66-
error "When using 'google_api_key', 'use_gemini_code_assist' cannot be 'true'."
65+
warn "When using 'google_api_key', 'use_gemini_code_assist' cannot be 'true'."
6766
fi
6867
fi
6968

7069
# Gemini API Key validation
7170
if [[ "${gemini_api_key_present}" == "true" ]]; then
7271
if [[ "${use_vertex_ai}" == "true" || "${use_gemini_code_assist}" == "true" ]]; then
73-
error "When using 'gemini_api_key', both 'use_vertex_ai' and 'use_gemini_code_assist' must be 'false'."
72+
warn "When using 'gemini_api_key', both 'use_vertex_ai' and 'use_gemini_code_assist' must be 'false'."
7473
fi
7574
fi

0 commit comments

Comments
 (0)