Skip to content

Fix Airflow proxy 500 on JS assets containing '$'/'\' (Airflow 3.2.2)#181

Merged
iliyan-velichkov merged 1 commit into
mainfrom
fix/airflow-proxy-illegal-group-reference
Jun 12, 2026
Merged

Fix Airflow proxy 500 on JS assets containing '$'/'\' (Airflow 3.2.2)#181
iliyan-velichkov merged 1 commit into
mainfrom
fix/airflow-proxy-illegal-group-reference

Conversation

@iliyan-velichkov

Copy link
Copy Markdown
Collaborator

Problem

After bumping apache/airflow from 3.0.2 to 3.2.2 (#1f987d7), opening the Airflow perspective fails: the request for static JS assets such as /services/airflow/static/assets/index-C6RXW4nO.js returns HTTP 500.

The container log shows:

java.lang.IllegalArgumentException: Illegal group reference
    at java.util.regex.Matcher.appendExpandedReplacement(Matcher.java:1113)
    at java.util.regex.Matcher.appendReplacement(Matcher.java:951)
    at com.codbex.phoebe.proxy.TextResponseBodyRewriter.rewriteFullURLs(TextResponseBodyRewriter.java:114)

Root cause

TextResponseBodyRewriter.rewriteFullURLs builds a replacement string from the matched path and feeds it to Matcher.appendReplacement. That method interprets $ as a capture-group reference and \ as an escape character. The new Airflow 3.2.2 minified JS bundle contains the Airflow URL immediately followed by paths that include $ / \ (common in minified JS), so an unescaped $/\ in the computed replacement throws IllegalArgumentException: Illegal group reference, which surfaces as a 500 and breaks the embedded UI.

Fix

Escape the replacement strings with Matcher.quoteReplacement(...) in rewriteFullURLs (the failing path) and, defensively, in rewriteEncodedQueryParams. Added a regression test (rewriteBody_shouldNotFail_whenAirflowUrlIsFollowedByDollarOrBackslash).

Testing

mvn test -P unit-tests -Dtest=TextResponseBodyRewriterTest -pl application — 6 tests pass.

🤖 Generated with Claude Code

After bumping apache/airflow to 3.2.2, opening the Airflow perspective
failed with HTTP 500 when loading static JS assets (e.g.
/services/airflow/static/assets/index-*.js):

    java.lang.IllegalArgumentException: Illegal group reference
        at java.util.regex.Matcher.appendReplacement
        at TextResponseBodyRewriter.rewriteFullURLs

The minified JS bundle contains the Airflow URL followed by paths that
include '$' (and '\') characters. Matcher.appendReplacement treats '$'
as a capture-group reference and '\' as an escape, so an unescaped
occurrence in the computed replacement string throws.

Escape the replacement strings with Matcher.quoteReplacement in both
rewriteFullURLs and rewriteEncodedQueryParams, and add a regression test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@iliyan-velichkov iliyan-velichkov self-assigned this Jun 12, 2026
@iliyan-velichkov iliyan-velichkov force-pushed the fix/airflow-proxy-illegal-group-reference branch from a7c0875 to f70f049 Compare June 12, 2026 11:46
@iliyan-velichkov iliyan-velichkov merged commit 03715c0 into main Jun 12, 2026
8 checks passed
@iliyan-velichkov iliyan-velichkov deleted the fix/airflow-proxy-illegal-group-reference branch June 12, 2026 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant