Skip to content

Percent-encode OTEL_RESOURCE_ATTRIBUTES values for strict OpenTelemetry consumers#39596

Merged
pelikhan merged 7 commits into
mainfrom
copilot/fix-unencoded-workflow-names
Jun 16, 2026
Merged

Percent-encode OTEL_RESOURCE_ATTRIBUTES values for strict OpenTelemetry consumers#39596
pelikhan merged 7 commits into
mainfrom
copilot/fix-unencoded-workflow-names

Conversation

Copilot AI commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

OTEL_RESOURCE_ATTRIBUTES was emitted with raw spaces and legacy backslash escaping, which is non-compliant with the OpenTelemetry env-var format. Strict SDKs can reject the entire resource when any attribute value is malformed, dropping all gh-aw.* attributes on downstream spans.

  • Compiler: emit spec-compliant resource attributes

    • Replace backslash escaping with RFC 3986 percent-encoding for OTEL_RESOURCE_ATTRIBUTES values.
    • Encode all non-unreserved bytes, covering spaces, commas, equals signs, backslashes, apostrophes, and similar characters in workflow names / engine IDs.
  • JS OTLP consumer: accept the new format

    • Update the in-repo JS parser to percent-decode attribute keys/values before building OTLP resource attributes.
    • Preserve compatibility with the previous gh-aw backslash-escaped format so existing inputs still parse.
  • Coverage updates

    • Adjust workflow OTLP tests to assert percent-encoded output for names and engine IDs containing reserved characters.
    • Add JS parsing coverage for percent-encoded OTEL_RESOURCE_ATTRIBUTES alongside legacy escaped input.

Example:

before:
gh-aw.workflow.name=My Workflow,gh-aw.engine.id=claude,eq=demo\test

after:
gh-aw.workflow.name=My%20Workflow,gh-aw.engine.id=claude%2Ceq%3Ddemo%5Ctest

Copilot AI and others added 2 commits June 16, 2026 16:26
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix unencoded workflow names in OTEL_RESOURCE_ATTRIBUTES Percent-encode OTEL_RESOURCE_ATTRIBUTES values for strict OpenTelemetry consumers Jun 16, 2026
Copilot AI requested a review from pelikhan June 16, 2026 16:37
@pelikhan pelikhan marked this pull request as ready for review June 16, 2026 16:48
Copilot AI review requested due to automatic review settings June 16, 2026 16:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates gh-aw’s OpenTelemetry resource attribute handling to emit RFC 3986 percent-encoded OTEL_RESOURCE_ATTRIBUTES values (instead of legacy backslash escaping) and teaches the in-repo JavaScript OTLP sender to percent-decode keys/values while remaining compatible with the legacy escape format.

Changes:

  • Go compiler: percent-encode all non-unreserved bytes in OTEL_RESOURCE_ATTRIBUTES dynamic values (workflow name, engine ID).
  • JS OTLP consumer: decode percent-encoded components while preserving legacy backslash-escape parsing behavior.
  • Tests: update/extend coverage to assert percent-encoded emission and percent-decoding.
Show a summary per file
File Description
pkg/workflow/observability_otlp.go Switches OTEL resource attribute value encoding to RFC 3986 percent-encoding.
pkg/workflow/observability_otlp_test.go Updates assertions to expect percent-encoded OTEL_RESOURCE_ATTRIBUTES output.
actions/setup/js/send_otlp_span.cjs Adds percent-decoding during OTEL_RESOURCE_ATTRIBUTES parsing while keeping legacy escape support.
actions/setup/js/send_otlp_span.test.cjs Adds a percent-encoded parsing test and updates span resource attribute expectations accordingly.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 4/4 changed files
  • Comments generated: 1

Comment thread pkg/workflow/observability_otlp.go Outdated
@@ -768,7 +764,21 @@ func otelServiceName(workflowData *WorkflowData) string {
}

func escapeOTELResourceAttributeValue(value string) string {
Comment thread pkg/workflow/observability_otlp.go Outdated

func escapeOTELResourceAttributeValue(value string) string {
return otelResourceValueEscaper.Replace(value)
const hexDigits = "0123456789ABCDEF"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot use native Go function from go packages to uri encode

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 8ee0539. This now uses Go's native URL-encoding helper (url.QueryEscape) with + normalized to %20, which preserves the RFC 3986 percent-encoded output required for OTEL_RESOURCE_ATTRIBUTES.

Copilot AI and others added 2 commits June 16, 2026 17:12
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI requested a review from pelikhan June 16, 2026 17:13
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

Copilot AI commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

@copilot run pr-finisher skill

Ran the finisher pass. No further code changes were needed; local make fmt, make lint, make test-unit, make test, and make recompile all passed on the current tip (8ee0539). CI on this head still needs a human re-trigger before merge.

@pelikhan pelikhan merged commit 96acd10 into main Jun 16, 2026
38 checks passed
@pelikhan pelikhan deleted the copilot/fix-unencoded-workflow-names branch June 16, 2026 17:42
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.

3 participants