Repository navigation
fix(#8672)!: resolve mint URL from config in dispatch workflows #9104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mfrancisc
wants to merge
39
commits into
fullsend-ai:main
Choose a base branch
from
mfrancisc:fix/8672-workflow-mint-url-from-config
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,205
−118
Open
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
6820167
fix(#8672): resolve mint URL from config in dispatch workflows
mfrancisc bddf936
Merge branch 'main' into fix/8672-workflow-mint-url-from-config
mfrancisc e0cce73
fix(#8672): address PR 9104 review on mint URL resolver
mfrancisc 3873835
Merge branch 'main' into fix/8672-workflow-mint-url-from-config
mfrancisc 407e355
fix(#8672): gate mint URL resolver and align URL checks
mfrancisc 4f2d23c
Merge branch 'main' into fix/8672-workflow-mint-url-from-config
mfrancisc 61ddf39
fix(#8672)!: prefer config mint_url over FULLSEND_MINT_URL
mfrancisc 274b2de
ci(ci-local): pin yq so script-test matches GitHub runners
mfrancisc c62fa15
Merge branch 'main' into fix/8672-workflow-mint-url-from-config
mfrancisc 6e30f6a
Merge branch 'main' into fix/8672-workflow-mint-url-from-config
mfrancisc 0471562
test(#8672): cover fail-closed mint URL resolver branches
mfrancisc b0dd927
Merge branch 'main' into fix/8672-workflow-mint-url-from-config
mfrancisc 6db5779
test(#8672): isolate PATH in missing-yq resolver tests
mfrancisc 0336aa4
Merge branch 'main' into fix/8672-workflow-mint-url-from-config
mfrancisc a5731ae
Merge branch 'main' into fix/8672-workflow-mint-url-from-config
mfrancisc 23c2d4f
fix(#8672): notice when config mint_url overrides FULLSEND_MINT_URL
mfrancisc 36b3661
Merge branch 'main' into fix/8672-workflow-mint-url-from-config
mfrancisc 481761b
fix(#8672): keep vendored script lists in alphabetical order
mfrancisc 59668f9
Merge branch 'main' into fix/8672-workflow-mint-url-from-config
mfrancisc 063c582
fix(#8672): resolve mint URL from vendored defaults or workflow pin
mfrancisc e78f451
Merge branch 'main' into fix/8672-workflow-mint-url-from-config
mfrancisc c07729f
docs(#8672): document dispatch mint_url precedence and migration
mfrancisc c8cbead
Merge branch 'main' into fix/8672-workflow-mint-url-from-config
mfrancisc 1bad343
fix(#8672): strengthen mint resolver wiring tests and docs
mfrancisc 54fbd0d
Merge branch 'main' into fix/8672-workflow-mint-url-from-config
mfrancisc e61f1c6
Merge branch 'main' into fix/8672-workflow-mint-url-from-config
mfrancisc 1b17a4e
fix(#8672): omit mint host from config override notice
mfrancisc 56bac31
Merge branch 'main' into fix/8672-workflow-mint-url-from-config
mfrancisc c9791dc
fix(#8672): gofmt vendored script map after main merge
mfrancisc cd34567
fix(#8672): address matrix event_payload as an object in harness-run
mfrancisc 5276966
Merge branch 'main' into fix/8672-workflow-mint-url-from-config
mfrancisc 680fe83
Merge branch 'main' into fix/8672-workflow-mint-url-from-config
mfrancisc 4d1cbd9
Merge branch 'main' into fix/8672-workflow-mint-url-from-config
mfrancisc 89f1939
fix(#8672): accept loopback mint URLs from config
mfrancisc b74a75c
chore: merge main into fix/8672-workflow-mint-url-from-config
mfrancisc 6367e32
fix(#8672): resolve review skip tokens from layered mint URL
mfrancisc 3501310
Merge branch 'main' into fix/8672-workflow-mint-url-from-config
mfrancisc 59b967a
fix(#8672)!: keep review fallback independent of masked mint URL
mfrancisc b82877b
Merge branch 'main' into fix/8672-workflow-mint-url-from-config
mfrancisc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,295 @@ | ||
| #!/usr/bin/env bash | ||
|
mfrancisc marked this conversation as resolved.
Resolved
|
||
| # resolve-effective-mint-url-test.sh — Tests for resolve-effective-mint-url.sh | ||
| # | ||
| # Run from the repo root: | ||
| # bash .github/scripts/resolve-effective-mint-url-test.sh | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| SCRIPT="${SCRIPT_DIR}/resolve-effective-mint-url.sh" | ||
| BASH_ABS="$(command -v bash)" | ||
| FAILURES=0 | ||
|
|
||
| if ! command -v yq >/dev/null 2>&1; then | ||
| echo "FAIL: yq is required to run resolve-effective-mint-url-test.sh" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| TMPDIR="$(mktemp -d)" | ||
|
mfrancisc marked this conversation as resolved.
Resolved
|
||
| trap 'rm -rf "${TMPDIR}"' EXIT | ||
|
|
||
| run_resolve() { | ||
| local fallback="${1:-}" | ||
| local output_file="${TMPDIR}/github-output.txt" | ||
| local stderr_file="${TMPDIR}/resolve-stderr.txt" | ||
| local oldpwd="${PWD}" | ||
| : >"${output_file}" | ||
| : >"${stderr_file}" | ||
|
mfrancisc marked this conversation as resolved.
Resolved
|
||
| cd "${TMPDIR}/repo" | ||
| GITHUB_OUTPUT="${output_file}" FALLBACK_MINT_URL="${fallback}" "${BASH_ABS}" "${SCRIPT}" 2>"${stderr_file}" | ||
| cd "${oldpwd}" | ||
| grep '^mint_url=' "${output_file}" | cut -d= -f2- | ||
| } | ||
|
|
||
| run_resolve_stderr() { | ||
| local fallback="${1:-}" | ||
| local output_file="${TMPDIR}/github-output.txt" | ||
| local stderr_file="${TMPDIR}/resolve-stderr.txt" | ||
| local oldpwd="${PWD}" | ||
| : >"${output_file}" | ||
| : >"${stderr_file}" | ||
| cd "${TMPDIR}/repo" | ||
| GITHUB_OUTPUT="${output_file}" FALLBACK_MINT_URL="${fallback}" "${BASH_ABS}" "${SCRIPT}" 2>"${stderr_file}" | ||
| cd "${oldpwd}" | ||
| cat "${stderr_file}" | ||
| } | ||
|
|
||
| assert_notice_contains() { | ||
| local name="$1" want="$2" stderr="$3" | ||
| if ! grep -F -- "${want}" <<<"${stderr}" >/dev/null; then | ||
| echo "FAIL: ${name}: expected notice containing ${want@Q}, stderr=${stderr@Q}" | ||
|
mfrancisc marked this conversation as resolved.
Resolved
|
||
| FAILURES=$((FAILURES + 1)) | ||
| fi | ||
| } | ||
|
|
||
| assert_no_notice_override() { | ||
| local name="$1" stderr="$2" | ||
| if grep -F -- "overrides FULLSEND_MINT_URL" <<<"${stderr}" >/dev/null; then | ||
| echo "FAIL: ${name}: unexpected override notice in stderr=${stderr@Q}" | ||
| FAILURES=$((FAILURES + 1)) | ||
| fi | ||
| } | ||
|
|
||
| run_resolve_expect_fail() { | ||
| local fallback="${1:-}" | ||
| local name="${2}" | ||
| local expected="${3}" | ||
| local leak="${4:-}" | ||
| local output_file="${TMPDIR}/github-output.txt" | ||
| local stderr_file="${TMPDIR}/stderr.txt" | ||
| local oldpwd="${PWD}" | ||
| local got | ||
| local script_path="${RESOLVE_PATH:-${PATH}}" | ||
| : >"${output_file}" | ||
| : >"${stderr_file}" | ||
| cd "${TMPDIR}/repo" | ||
| if PATH="${script_path}" GITHUB_OUTPUT="${output_file}" FALLBACK_MINT_URL="${fallback}" "${BASH_ABS}" "${SCRIPT}" 2>"${stderr_file}"; then | ||
| cd "${oldpwd}" | ||
| echo "FAIL: ${name}: expected non-zero exit" | ||
| FAILURES=$((FAILURES + 1)) | ||
| return 0 | ||
|
mfrancisc marked this conversation as resolved.
Resolved
|
||
| fi | ||
| cd "${oldpwd}" | ||
| got="$(cat "${stderr_file}")" | ||
| if ! grep -F -- "${expected}" "${stderr_file}" >/dev/null; then | ||
| echo "FAIL: ${name}: expected ${expected@Q} in stderr, got ${got@Q}" | ||
| FAILURES=$((FAILURES + 1)) | ||
| fi | ||
| if [[ -n "${leak}" ]] && grep -F -- "${leak}" "${stderr_file}" >/dev/null; then | ||
| echo "FAIL: ${name}: stderr leaked ${leak@Q}" | ||
| FAILURES=$((FAILURES + 1)) | ||
| fi | ||
| } | ||
|
|
||
| setup_repo() { | ||
| rm -rf "${TMPDIR}/repo" | ||
| mkdir -p "${TMPDIR}/repo/.fullsend" | ||
| cd "${TMPDIR}/repo" | ||
| } | ||
|
|
||
| assert_eq() { | ||
| local name="$1" want="$2" got="$3" | ||
| if [[ "${want}" != "${got}" ]]; then | ||
| echo "FAIL: ${name}: want ${want@Q}, got ${got@Q}" | ||
| if [[ -s "${TMPDIR}/resolve-stderr.txt" ]]; then | ||
| echo "Resolver stderr:" | ||
| cat "${TMPDIR}/resolve-stderr.txt" | ||
| fi | ||
| FAILURES=$((FAILURES + 1)) | ||
| fi | ||
| } | ||
|
|
||
|
mfrancisc marked this conversation as resolved.
Resolved
|
||
| setup_repo | ||
| if (unset GITHUB_OUTPUT; FALLBACK_MINT_URL="https://fallback.example" "${BASH_ABS}" "${SCRIPT}" 2>"${TMPDIR}/resolve-stderr.txt"); then | ||
| echo "FAIL: missing GITHUB_OUTPUT: expected non-zero exit" | ||
| FAILURES=$((FAILURES + 1)) | ||
| else | ||
| assert_notice_contains "missing GITHUB_OUTPUT" "GITHUB_OUTPUT is required" "$(cat "${TMPDIR}/resolve-stderr.txt")" | ||
| fi | ||
|
|
||
| setup_repo | ||
| assert_eq "fallback only" "https://fallback.example" "$(run_resolve "https://fallback.example")" | ||
|
|
||
| setup_repo | ||
| printf 'version: "1"\nmint_url: https://overlay.example\n' >.fullsend/config.yaml | ||
|
mfrancisc marked this conversation as resolved.
Resolved
|
||
| assert_eq "overlay wins" "https://overlay.example" "$(run_resolve "https://fallback.example")" | ||
| assert_notice_contains "overlay override notice" "mint_url from .fullsend config overrides FULLSEND_MINT_URL" "$(run_resolve_stderr "https://fallback.example")" | ||
|
|
||
| setup_repo | ||
| printf 'version: "1"\nmint_url: https://same.example\n' >.fullsend/config.yaml | ||
| assert_eq "file matches fallback" "https://same.example" "$(run_resolve "https://same.example")" | ||
| assert_no_notice_override "no notice when values match" "$(run_resolve_stderr "https://same.example")" | ||
|
|
||
| setup_repo | ||
| assert_no_notice_override "no notice for fallback only" "$(run_resolve_stderr "https://fallback.example")" | ||
|
|
||
| setup_repo | ||
| printf 'version: "1"\nmint_url: https://base.example\n' >.fullsend/config.base.yaml | ||
| assert_eq "base only" "https://base.example" "$(run_resolve "https://fallback.example")" | ||
| assert_notice_contains "base override notice" "mint_url from .fullsend config overrides FULLSEND_MINT_URL" "$(run_resolve_stderr "https://fallback.example")" | ||
|
|
||
| setup_repo | ||
| printf 'version: "1"\n' >.fullsend/config.yaml | ||
| printf 'version: "1"\nmint_url: https://base.example\n' >.fullsend/config.base.yaml | ||
| assert_eq "silent overlay uses base" "https://base.example" "$(run_resolve "https://fallback.example")" | ||
|
|
||
| setup_repo | ||
| printf 'version: "1"\nmint_url: https://overlay.example\n' >.fullsend/config.yaml | ||
| printf 'version: "1"\nmint_url: https://base.example\n' >.fullsend/config.base.yaml | ||
| assert_eq "overlay beats base" "https://overlay.example" "$(run_resolve "https://fallback.example")" | ||
|
|
||
| setup_repo | ||
| printf 'version: "1"\nmint_url: null\n' >.fullsend/config.yaml | ||
| printf 'version: "1"\nmint_url: https://base.example\n' >.fullsend/config.base.yaml | ||
| assert_eq "null overlay uses base" "https://base.example" "$(run_resolve "https://fallback.example")" | ||
|
|
||
| setup_repo | ||
| printf 'version: "1"\nmint_url: ""\n' >.fullsend/config.yaml | ||
| printf 'version: "1"\nmint_url: https://base.example\n' >.fullsend/config.base.yaml | ||
| assert_eq "empty overlay uses base" "https://base.example" "$(run_resolve "https://fallback.example")" | ||
|
|
||
| setup_repo | ||
| printf 'version: "1"\nmint_url: ""\n' >.fullsend/config.base.yaml | ||
| assert_eq "empty base uses fallback" "https://fallback.example" "$(run_resolve "https://fallback.example")" | ||
|
|
||
| setup_repo | ||
| printf 'version: "1"\nmint_url: null\n' >.fullsend/config.yaml | ||
| assert_eq "null overlay uses fallback" "https://fallback.example" "$(run_resolve "https://fallback.example")" | ||
|
|
||
| setup_repo | ||
| printf 'version: "1"\nmint_url: "null"\n' >.fullsend/config.yaml | ||
| assert_eq "literal null overlay uses fallback" "https://fallback.example" "$(run_resolve "https://fallback.example")" | ||
|
|
||
| setup_repo | ||
| assert_eq "empty fallback" "" "$(run_resolve "")" | ||
|
|
||
| setup_repo | ||
| printf 'version: "1"\nmint_url: http://evil.example\n' >.fullsend/config.yaml | ||
| run_resolve_expect_fail "https://fallback.example" "reject non-loopback http from config" "::error::mint_url must be a valid HTTPS URL, or HTTP on localhost/127.0.0.1" | ||
|
mfrancisc marked this conversation as resolved.
Resolved
|
||
|
|
||
| setup_repo | ||
| printf 'version: "1"\nmint_url: https://user:pass@mint.example\n' >.fullsend/config.yaml | ||
| run_resolve_expect_fail "https://fallback.example" "reject userinfo mint_url" "::error::mint_url must not contain userinfo" "user:pass" | ||
|
|
||
| setup_repo | ||
| printf 'version: "1"\nmint_url: https://mint.example/a@b\n' >.fullsend/config.yaml | ||
| assert_eq "at-sign in path is not userinfo" "https://mint.example/a@b" "$(run_resolve "")" | ||
|
|
||
| setup_repo | ||
| printf 'version: "1"\nmint_url: HTTPS://mint.example\n' >.fullsend/config.yaml | ||
| run_resolve_expect_fail "" "reject uppercase scheme (Go parity)" "::error::mint_url must be a valid HTTPS URL" | ||
|
|
||
| setup_repo | ||
| assert_eq "localhost http fallback" "http://localhost:8080" "$(run_resolve "http://localhost:8080")" | ||
|
|
||
| setup_repo | ||
| assert_eq "loopback http fallback" "http://127.0.0.1:8080" "$(run_resolve "http://127.0.0.1:8080")" | ||
|
|
||
| setup_repo | ||
| printf 'version: "1"\nmint_url: http://127.0.0.1:18502\n' >.fullsend/config.yaml | ||
| assert_eq "emulator loopback http in overlay and fallback" "http://127.0.0.1:18502" "$(run_resolve "http://127.0.0.1:18502")" | ||
|
|
||
| setup_repo | ||
| printf 'version: "1"\nmint_url: http://localhost:8080\n' >.fullsend/config.base.yaml | ||
| assert_eq "localhost http from base config" "http://localhost:8080" "$(run_resolve "https://fallback.example")" | ||
|
|
||
| setup_repo | ||
| run_resolve_expect_fail "http://evil.example" "reject non-loopback http fallback" "::error::mint_url must be a valid HTTPS URL, or HTTP on localhost/127.0.0.1" | ||
|
|
||
| setup_repo | ||
| run_resolve_expect_fail "https://u:p@host" "reject userinfo fallback" "::error::mint_url must not contain userinfo" "u:p" | ||
|
|
||
| setup_repo | ||
| run_resolve_expect_fail "http://user@127.0.0.1" "Go rejects loopback userinfo" "::error::mint_url must not contain userinfo" "user@" | ||
|
|
||
| # Mirror the URL cases in internal/urlutil.TestIsMintURL. The resolver | ||
| # deliberately permits an empty value: mint-token reports that separately. | ||
| for valid_url in \ | ||
| "https://mint.example.com" \ | ||
| "https://mint.example.com/v1/token" \ | ||
| "http://127.0.0.1:18502" \ | ||
| "http://localhost"; do | ||
| setup_repo | ||
| assert_eq "Go accepts ${valid_url}" "${valid_url}" "$(run_resolve "${valid_url}")" | ||
| done | ||
|
|
||
| for invalid_url in \ | ||
| "http://10.0.0.1" \ | ||
| "http://example.com" \ | ||
| "https://" \ | ||
| "http:///path" \ | ||
| "ftp://127.0.0.1" \ | ||
| "https://mint.example " \ | ||
| "https://host:abc" \ | ||
| $'https://mint.example\t/path'; do | ||
| setup_repo | ||
| run_resolve_expect_fail "${invalid_url}" "Go rejects ${invalid_url}" "::error::mint_url must be a valid HTTPS URL" | ||
| done | ||
|
|
||
| setup_repo | ||
| run_resolve_expect_fail $'https://mint.example\nsmuggled' "reject LF in fallback" "::error::mint_url must not contain CR or LF" | ||
|
mfrancisc marked this conversation as resolved.
Resolved
|
||
|
|
||
| setup_repo | ||
| run_resolve_expect_fail $'https://mint.example\rsmuggled' "reject CR in fallback" "::error::mint_url must not contain CR or LF" | ||
|
|
||
| setup_repo | ||
| printf 'mint_url: [unclosed\n' >.fullsend/config.yaml | ||
| run_resolve_expect_fail "https://fallback.example" "reject unparsable overlay" "::error::failed to read mint_url from .fullsend/config.yaml" | ||
|
|
||
| setup_repo | ||
| printf 'version: "1"\n' >.fullsend/config.yaml | ||
| printf 'mint_url: [unclosed\n' >.fullsend/config.base.yaml | ||
| run_resolve_expect_fail "https://fallback.example" "reject unparsable base under silent overlay" "::error::failed to read mint_url from .fullsend/config.base.yaml" | ||
|
|
||
| # Isolate PATH so yq is missing without dropping bash/tr from system | ||
| # directories that also contain yq (for example /usr/bin on merged-/usr). | ||
| noyq_bin="${TMPDIR}/noyq-bin" | ||
| mkdir -p "${noyq_bin}" | ||
| for _cmd in bash tr grep cut cat; do | ||
| _src="$(command -v "${_cmd}")" | ||
| if [[ -z "${_src}" || ! -x "${_src}" ]]; then | ||
| echo "FAIL: required tool ${_cmd} not found on PATH" | ||
| exit 1 | ||
| fi | ||
| ln -s "${_src}" "${noyq_bin}/${_cmd}" | ||
| done | ||
| if PATH="${noyq_bin}" command -v yq >/dev/null 2>&1; then | ||
| echo "FAIL: isolated PATH still finds yq" | ||
| exit 1 | ||
| fi | ||
|
|
||
| run_resolve_without_yq() { | ||
| local fallback="${1:-}" | ||
| local output_file="${TMPDIR}/github-output.txt" | ||
| local oldpwd="${PWD}" | ||
| : >"${output_file}" | ||
| cd "${TMPDIR}/repo" | ||
| PATH="${noyq_bin}" GITHUB_OUTPUT="${output_file}" FALLBACK_MINT_URL="${fallback}" "${BASH_ABS}" "${SCRIPT}" | ||
| cd "${oldpwd}" | ||
| grep '^mint_url=' "${output_file}" | cut -d= -f2- | ||
| } | ||
|
|
||
| setup_repo | ||
| assert_eq "no yq without config files" "https://fallback.example" "$(run_resolve_without_yq "https://fallback.example")" | ||
|
|
||
| setup_repo | ||
| printf 'version: "1"\nmint_url: https://overlay.example\n' >.fullsend/config.yaml | ||
| RESOLVE_PATH="${noyq_bin}" run_resolve_expect_fail "https://fallback.example" "yq required when config files exist" "::error::yq is required to resolve mint_url from config" | ||
|
mfrancisc marked this conversation as resolved.
Resolved
|
||
|
|
||
| if [[ "${FAILURES}" -eq 0 ]]; then | ||
| echo "All tests passed." | ||
| else | ||
| echo "${FAILURES} test(s) failed." | ||
| exit 1 | ||
| fi | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.