Conversation
| CHAIN_NAME=$(echo "$chain" | jq -r '.chain') | ||
| PORT=$(echo "$chain" | jq -r '.port') | ||
|
|
||
| # Get endpoints from runtimes-matrix.json | ||
| ENDPOINTS=$(jq -r --arg chain "$CHAIN_NAME" '.[] | select(.name == $chain) | .uris | map("\"" + . + "\"") | join(", ")' .github/workflows/runtimes-matrix.json) | ||
|
|
||
| echo "Starting Subway for $CONFIG on port $PORT..." | ||
| sed "s/{{PORT}}/$PORT/g" .github/subway-configs/$CONFIG > /tmp/subway-$PORT.yml | ||
| echo "Starting Subway for $CHAIN_NAME on port $PORT..." | ||
| sed -e "s/{{PORT}}/$PORT/g" -e "s|{{ENDPOINTS}}|$ENDPOINTS|g" .github/subway-configs/template.yml > /tmp/subway-$PORT.yml |
There was a problem hiding this comment.
The loop uses ... | while read chain; do (without -r) and then parses JSON from $chain. read will treat backslashes as escapes, which can corrupt JSON strings. Use while IFS= read -r chain; do to ensure the JSON line is read verbatim.
| echo "Starting Subway for $CONFIG on port $PORT..." | ||
| sed "s/{{PORT}}/$PORT/g" .github/subway-configs/$CONFIG > /tmp/subway-$PORT.yml | ||
| echo "Starting Subway for $CHAIN_NAME on port $PORT..." | ||
| sed -e "s/{{PORT}}/$PORT/g" -e "s|{{ENDPOINTS}}|$ENDPOINTS|g" .github/subway-configs/template.yml > /tmp/subway-$PORT.yml |
There was a problem hiding this comment.
The sed replacement injects $ENDPOINTS directly into the replacement string. If any URI ever contains & (sed replacement expands & to the matched text) or the chosen delimiter (|), the generated YAML will be corrupted. Either escape the replacement (ENDPOINTS_ESCAPED=$(printf '%s' "$ENDPOINTS" | sed 's/[&|\\]/\\&/g')) before sed, or avoid sed entirely by generating the YAML with a templating-safe approach (e.g., have jq emit the full JSON array and substitute that).
|
Review required! Latest push from author must always be reviewed |
|
|
||
| echo "Starting Subway for $CONFIG on port $PORT..." | ||
| sed "s/{{PORT}}/$PORT/g" .github/subway-configs/$CONFIG > /tmp/subway-$PORT.yml | ||
| ENDPOINTS=$(jq -c --arg chain "$CHAIN_NAME" '.[] | select(.name == $chain) | .uris' .github/workflows/runtimes-matrix.json) |
There was a problem hiding this comment.
Huh. I must have prompted Claude incorrectly, if I wasn't able to find this file.
Uh oh!
There was an error while loading. Please reload this page.