Skip to content

Issue 1229 fix: Application Insights connection string shell splitting on semicolon#1275

Open
stokpop wants to merge 1 commit into
cloudfoundry:mainfrom
stokpop:issue-1229-fix-connection-string-shell-quoting
Open

Issue 1229 fix: Application Insights connection string shell splitting on semicolon#1275
stokpop wants to merge 1 commit into
cloudfoundry:mainfrom
stokpop:issue-1229-fix-connection-string-shell-quoting

Conversation

@stokpop
Copy link
Copy Markdown
Contributor

@stokpop stokpop commented May 15, 2026

Problem

When APPLICATIONINSIGHTS_CONNECTION_STRING contains a semicolon (e.g., InstrumentationKey=...;IngestionEndpoint=https://...), the application fails to start.

The start command uses:

eval exec $JAVA_HOME/bin/java $JAVA_OPTS -jar app.jar

Because $JAVA_OPTS is unquoted, bash's eval treats the semicolon as a command separator. Java runs without -jar app.jar, prints usage output, and exits 1. The agent starts correctly but the application never launches.

Fixes #1229.

Root cause

The -Dapplicationinsights.connection.string=KEY;Endpoint=... token is split by eval at the ;.

Fix

Single-quote the connection string value in the opts file:

-Dapplicationinsights.connection.string='KEY;Endpoint=...'

Single quoting is safe here because Azure connection strings never contain single quotes. The JVM receives the full value correctly after eval expands the shell command.

Tests

Added/updated 4 tests in azure_application_insights_agent_test.go covering:

  • Env var with semicolon in connection string
  • Service binding (snake_case) with semicolon
  • Service binding (camelCase) with semicolon
  • Precedence: connection string over instrumentation key (also with semicolon)

…tring

When APPLICATIONINSIGHTS_CONNECTION_STRING contains a semicolon (e.g.,
InstrumentationKey=...;IngestionEndpoint=...), the start command:

  eval exec $JAVA_HOME/bin/java $JAVA_OPTS -jar app.jar

splits on the semicolon because $JAVA_OPTS is unquoted. Bash treats the
semicolon as a command separator, so java runs without -jar, prints usage,
and exits 1.

Fix: single-quote the connection string value in the opts file:
  -Dapplicationinsights.connection.string='KEY;Endpoint=...'

This is safe because connection strings never contain single quotes.
The JVM receives the full value correctly after eval.
@stokpop stokpop changed the title Fix Application Insights connection string shell splitting on semicolon Fix issue 1229: Application Insights connection string shell splitting on semicolon May 15, 2026
@stokpop stokpop changed the title Fix issue 1229: Application Insights connection string shell splitting on semicolon Issue 1229 fix: Application Insights connection string shell splitting on semicolon May 15, 2026
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.

Custom java agent doesn't work with v5

1 participant