Skip to content

fix(auth): skip expected missing-header telemetry#2645

Draft
tvi wants to merge 1 commit into
mainfrom
t/auth-log-fix
Draft

fix(auth): skip expected missing-header telemetry#2645
tvi wants to merge 1 commit into
mainfrom
t/auth-log-fix

Conversation

@tvi
Copy link
Copy Markdown
Contributor

@tvi tvi commented May 13, 2026

Missing auth headers are a normal unauthorized path, so avoid reporting ErrNoAuthHeader as an error while preserving telemetry for unexpected header parsing failures.

Missing auth headers are a normal unauthorized path, so avoid reporting ErrNoAuthHeader as an error while preserving telemetry for unexpected header parsing failures.
@cla-bot cla-bot Bot added the cla-signed label May 13, 2026
@cursor
Copy link
Copy Markdown

cursor Bot commented May 13, 2026

PR Summary

Low Risk
Low risk change limited to telemetry emission on unauthorized requests; behavior still returns 401 for missing headers. Main risk is reduced observability if ErrNoAuthHeader is wrapped differently than expected, causing the error to be silently skipped.

Overview
Stops calling telemetry.ReportError when header extraction fails specifically with ErrNoAuthHeader, while keeping the 401 response and continuing to report telemetry for other header parsing failures.

Reviewed by Cursor Bugbot for commit 1c01dff. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1c01dff. Configure here.

)
if !errors.Is(err, ErrNoAuthHeader) {
telemetry.ReportError(ctx,
"authorization header is missing",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Telemetry message misleading after conditional skip

Low Severity

The telemetry.ReportError message "authorization header is missing" now only fires for ErrInvalidAuthHeader (malformed header), since ErrNoAuthHeader is explicitly excluded by the new guard. The telemetry event description no longer matches the actual error condition — it will misleadingly report "missing" when the header was present but malformed.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1c01dff. Configure here.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

❌ 4 Tests Failed:

Tests completed Failed Passed Skipped
2618 4 2614 7
View the full list of 7 ❄️ flaky test(s)
github.com/e2b-dev/infra/tests/integration/internal/tests/api/sandboxes::TestUpdateNetworkConfig

Flake rate in main: 76.44% (Passed 164 times, Failed 532 times)

Stack Traces | 203s run time
=== RUN   TestUpdateNetworkConfig
=== PAUSE TestUpdateNetworkConfig
=== CONT  TestUpdateNetworkConfig
Executing command ssh in sandbox iam6wmhlrkd4arokqh3ur
--- FAIL: TestUpdateNetworkConfig (202.74s)
github.com/e2b-dev/infra/tests/integration/internal/tests/api/sandboxes::TestUpdateNetworkConfig/pause_resume_preserves_allow_internet_access_false

Flake rate in main: 76.90% (Passed 158 times, Failed 526 times)

Stack Traces | 6.67s run time
=== RUN   TestUpdateNetworkConfig/pause_resume_preserves_allow_internet_access_false
Executing command curl in sandbox ifgzcidve234fouuwvj5o
    sandbox_network_update_test.go:372: Command [curl] output: event:{start:{pid:1348}}
    sandbox_network_update_test.go:372: Command [curl] output: event:{end:{exit_code:35  exited:true  status:"exit status 35"  error:"exit status 35"}}
Executing command curl in sandbox ifgzcidve234fouuwvj5o
    sandbox_network_update_test.go:372: Command [curl] output: event:{start:{pid:1349}}
    sandbox_network_update_test.go:372: Command [curl] output: event:{end:{exit_code:35  exited:true  status:"exit status 35"  error:"exit status 35"}}
Executing command test in sandbox idvyrr73uxp1cgp0pnmws
    sandbox_network_update_test.go:391: Command [curl] output: event:{start:{pid:1350}}
    sandbox_network_update_test.go:391: Command [curl] output: event:{data:{stdout:"HTTP/2 302 \r\nx-content-type-options: nosniff\r\nlocation: https://dns.google/\r\ndate: Wed, 13 May 2026 19:32:06 GMT\r\ncontent-type: text/html; charset=UTF-8\r\nserver: HTTP server (unknown)\r\ncontent-length: 216\r\nx-xss-protection: 0\r\nx-frame-options: SAMEORIGIN\r\nalt-svc: h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000\r\n\r\n"}}
    sandbox_network_update_test.go:391: Command [curl] output: event:{end:{exited:true  status:"exit status 0"}}
    sandbox_network_update_test.go:391: Command [curl] completed successfully in sandbox ifgzcidve234fouuwvj5o
    sandbox_network_update_test.go:391: 
        	Error Trace:	.../api/sandboxes/sandbox_network_out_test.go:74
        	            				.../api/sandboxes/sandbox_network_update_test.go:60
        	            				.../api/sandboxes/sandbox_network_update_test.go:391
        	Error:      	An error is expected but got nil.
        	Test:       	TestUpdateNetworkConfig/pause_resume_preserves_allow_internet_access_false
        	Messages:   	https://8.8.8.8 should be blocked
--- FAIL: TestUpdateNetworkConfig/pause_resume_preserves_allow_internet_access_false (6.67s)
github.com/e2b-dev/infra/tests/integration/internal/tests/api/templates::TestTemplateBuildCOPY

Flake rate in main: 54.36% (Passed 157 times, Failed 187 times)

Stack Traces | 20.1s run time
=== RUN   TestTemplateBuildCOPY
=== PAUSE TestTemplateBuildCOPY
=== CONT  TestTemplateBuildCOPY
    build_template_test.go:134: test-ubuntu-copy: [info] Building template hausyqnvfqrpdccgo7wa/4b623566-492f-4fbb-af7e-94e3f3da81e4
    build_template_test.go:134: test-ubuntu-copy: [info] [base] FROM ubuntu:24.04 [33c3d1f55ae33f402733ec22d91cfbce7572f860c9bb4d15b497c19d978167b5]
    build_template_test.go:134: test-ubuntu-copy: [info] Base Docker image size: 30 MB
    build_template_test.go:134: test-ubuntu-copy: [info] Creating file system and pulling Docker image
    build_template_test.go:134: test-ubuntu-copy: [info] Uncompressing layer sha256:b40150c1c2717d324cdb17278c8efdfa4dfcd2ffe083e976f0bcedf31115f081 30 MB
    build_template_test.go:134: test-ubuntu-copy: [info] Uncompressing layer sha256:192976976766f12c507e0e528220bea16308860355a8c1b9ccbf773f983516a0 12 MB
    build_template_test.go:134: test-ubuntu-copy: [info] Uncompressing layer sha256:8c4b1b28875140ed3abacaf16ad0d696f6bef912f52d2148f261a23e3349465b 168 B
    build_template_test.go:134: test-ubuntu-copy: [info] Layers extracted
    build_template_test.go:134: test-ubuntu-copy: [info] Root filesystem structure: bin, boot, dev, etc, home, lib, lib64, media, mnt, opt, proc, root, run, sbin, srv, sys, tmp, usr, var
    build_template_test.go:134: test-ubuntu-copy: [error] Build failed: An internal error occurred. Please try again or contact support with the build ID.
    build_template_test.go:1153: Build failed: {<nil> An internal error occurred. Please try again or contact support with the build ID. <nil>}
--- FAIL: TestTemplateBuildCOPY (20.15s)
github.com/e2b-dev/infra/tests/integration/internal/tests/api/templates::TestTemplateBuildENV

Flake rate in main: 58.67% (Passed 155 times, Failed 220 times)

Stack Traces | 0s run time
=== RUN   TestTemplateBuildENV
=== PAUSE TestTemplateBuildENV
=== CONT  TestTemplateBuildENV
--- FAIL: TestTemplateBuildENV (0.00s)
github.com/e2b-dev/infra/tests/integration/internal/tests/api/templates::TestTemplateBuildENV/ENV_with_multiline_value

Flake rate in main: 59.45% (Passed 148 times, Failed 217 times)

Stack Traces | 7.09s run time
=== RUN   TestTemplateBuildENV/ENV_with_multiline_value
=== PAUSE TestTemplateBuildENV/ENV_with_multiline_value
=== CONT  TestTemplateBuildENV/ENV_with_multiline_value
    build_template_test.go:134: test-ubuntu-env-multiline: [info] Building template 6c29eh4x2jepbl7lm0f9/d82eaba5-f1e7-4228-982d-b2c613840522
    build_template_test.go:134: test-ubuntu-env-multiline: [info] CACHED [base] FROM ubuntu:22.04 [ffd709f131f42dfab282de47a91dd2c139e900c1c11fc574b49b517a05ef0a32]
    build_template_test.go:134: test-ubuntu-env-multiline: [info] CACHED [base] DEFAULT USER user [90bdd4afa342293c931373351bf578872dec9179214ba3e8bf9edba311466213]
    build_template_test.go:134: test-ubuntu-env-multiline: [info] [builder 1/2] ENV MULTILINE line1
        line2
        line3 [e93da3f3765f20eb6407c336b9e4e0b9321d994ec5f6cb547743a2a4070eed23]
    build_template_test.go:134: test-ubuntu-env-multiline: [info] [builder 2/2] RUN [[ $(echo "$MULTILINE" | wc -l) -eq 3 ]] || exit 1 [477610d61cdf858776262d3331809539bcbcf16f706aac18515a57337bae1786]
    build_template_test.go:134: test-ubuntu-env-multiline: [error] Build failed: failed to run command '[[ $(echo "$MULTILINE" | wc -l) -eq 3 ]] || exit 1': exit status 1
    build_template_test.go:374: Build failed: {<nil> failed to run command '[[ $(echo "$MULTILINE" | wc -l) -eq 3 ]] || exit 1': exit status 1 0xc000890620}
--- FAIL: TestTemplateBuildENV/ENV_with_multiline_value (7.09s)
github.com/e2b-dev/infra/tests/integration/internal/tests/orchestrator::TestSandboxMemoryIntegrity

Flake rate in main: 66.05% (Passed 164 times, Failed 319 times)

Stack Traces | 82.4s run time
=== RUN   TestSandboxMemoryIntegrity
=== PAUSE TestSandboxMemoryIntegrity
=== CONT  TestSandboxMemoryIntegrity
    sandbox_memory_integrity_test.go:26: Build completed successfully
--- FAIL: TestSandboxMemoryIntegrity (82.38s)
github.com/e2b-dev/infra/tests/integration/internal/tests/orchestrator::TestSandboxMemoryIntegrity/tmpfs_hash

Flake rate in main: 67.02% (Passed 154 times, Failed 313 times)

Stack Traces | 43.6s run time
=== RUN   TestSandboxMemoryIntegrity/tmpfs_hash
=== PAUSE TestSandboxMemoryIntegrity/tmpfs_hash
=== CONT  TestSandboxMemoryIntegrity/tmpfs_hash
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{start:{pid:1258}}
Executing command bash in sandbox ih8n9euig6avt336nyvc5 (user: root)
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stdout:"Total memory: 985 MB\nUsed memory before tmpfs mount: 180 MB\nFree memory before tmpfs mount: 804 MB\n"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stdout:"Memory to use in integrity test (80% of free, min 64MB): 643 MB\n"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"643+0 records in\n643+0 records out\n674234368 bytes (674 MB, 643 MiB) copied, 3.21222 s, 210 MB/s\n"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"\tCommand being timed: \"dd if=/dev/urandom of=/mnt/testfile bs=1M count=643\"\n\tUser time (seconds): 0.00\n\tSystem time (seconds): 3.18\n\tPercent of CPU this job got: 98%\n\tElapsed (wall clock) time (h:mm:ss or m:ss): 0:03.21\n\tAverage shared text size (kbytes): 0\n\tAverage unshared data size (kbytes): 0\n\tAverage stack size (kbytes): 0\n\tAverage total size (kbytes): 0\n\tMaximum resident set size (kbytes): 2724\n\tAverage resident set size (kbytes): 0\n\tMajor (requiring I/O) page faults: 2\n\tMinor (reclaiming a frame) page faults: 345\n\tVoluntary context switches: 3\n\tInvoluntary context switches: 27\n\tSwaps: 0\n\tFile system inputs: 176\n\tFile system outputs: 0\n\tSocket messages sent: 0\n\tSocket messages received: 0\n\tSignals delivered: 0\n\tPage size (bytes): 4096\n\tExit status: 0\n"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stdout:"Used memory after tmpfs mount and file fill: 831 MB\n"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{end:{exited:true status:"exit status 0"}}
    sandbox_memory_integrity_test.go:70: Command [bash] completed successfully in sandbox in68t188ays5fswnas5vf
Executing command bash in sandbox in68t188ays5fswnas5vf (user: root)
    sandbox_memory_integrity_test.go:74: Command [bash] output: event:{start:{pid:1274}}
    sandbox_memory_integrity_test.go:74: Command [bash] output: event:{data:{stdout:"5dcf76996c88c5a0f35326f6b6ace5c7f2166cf501c842aa9567c9e23383b2de\n"}}
    sandbox_memory_integrity_test.go:74: Command [bash] output: event:{end:{exited:true status:"exit status 0"}}
    sandbox_memory_integrity_test.go:74: Command [bash] completed successfully in sandbox in68t188ays5fswnas5vf
Executing command bash in sandbox in68t188ays5fswnas5vf (user: root)
    sandbox_memory_integrity_test.go:99: Command [bash] output: event:{start:{pid:1277}}
    sandbox_memory_integrity_test.go:99: Command [bash] output: event:{data:{stdout:"5dcf76996c88c5a0f35326f6b6ace5c7f2166cf501c842aa9567c9e23383b2de\n"}}
    sandbox_memory_integrity_test.go:99: Command [bash] output: event:{end:{exited:true status:"exit status 0"}}
    sandbox_memory_integrity_test.go:99: Command [bash] completed successfully in sandbox in68t188ays5fswnas5vf
Executing command bash in sandbox in68t188ays5fswnas5vf (user: root)
    sandbox_memory_integrity_test.go:99: Command [bash] output: event:{start:{pid:1280}}
    sandbox_memory_integrity_test.go:100: 
        	Error Trace:	.../tests/orchestrator/sandbox_memory_integrity_test.go:100
        	Error:      	Received unexpected error:
        	            	failed to execute command bash in sandbox in68t188ays5fswnas5vf: invalid_argument: protocol error: incomplete envelope: unexpected EOF
        	Test:       	TestSandboxMemoryIntegrity/tmpfs_hash
--- FAIL: TestSandboxMemoryIntegrity/tmpfs_hash (43.64s)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

The telemetry message "authorization header is missing" is incorrect because the logic now ensures the error is not ErrNoAuthHeader. The message should be updated to "authorization header is invalid" to correctly reflect the state when ErrInvalidAuthHeader is returned.

)
if !errors.Is(err, ErrNoAuthHeader) {
telemetry.ReportError(ctx,
"authorization header is missing",
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.

high

The telemetry message "authorization header is missing" is incorrect because the preceding check ensures the error is not ErrNoAuthHeader. The message should be updated to "authorization header is invalid" to correctly reflect the state when ErrInvalidAuthHeader is returned.

Suggested change
"authorization header is missing",
"authorization header is invalid",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants