Skip to content

fix(api): report invalid tag errors as bad requests#2799

Merged
jakubno merged 1 commit into
mainfrom
fix/template-tag-error-reporting
May 23, 2026
Merged

fix(api): report invalid tag errors as bad requests#2799
jakubno merged 1 commit into
mainfrom
fix/template-tag-error-reporting

Conversation

@jakubno
Copy link
Copy Markdown
Member

@jakubno jakubno commented May 22, 2026

No description provided.

@jakubno jakubno marked this pull request as ready for review May 22, 2026 09:58
@cla-bot cla-bot Bot added the cla-signed label May 22, 2026
@jakubno jakubno enabled auto-merge (squash) May 22, 2026 09:58
@cursor
Copy link
Copy Markdown

cursor Bot commented May 22, 2026

PR Summary

Low Risk
Low risk because this only changes telemetry severity for tag validation failures and does not affect persistence or authorization logic.

Overview
Invalid tag validation paths now call telemetry.ReportErrorByCode(..., http.StatusBadRequest, ...) instead of ReportError/ReportCriticalError, so these client-caused failures are consistently logged as non-critical 4xx errors. The main risk is reduced alerting/visibility if any of these “invalid tag” cases actually originate from server-side bugs rather than malformed input.

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

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

This pull request standardizes telemetry error reporting within the template request and tag handlers by replacing generic error reporting methods with telemetry.ReportErrorByCode, ensuring that the http.StatusBadRequest status code is correctly captured in telemetry. I have no feedback to provide as the changes are consistent and correctly implemented.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

❌ 3 Tests Failed:

Tests completed Failed Passed Skipped
2671 3 2668 7
View the full list of 3 ❄️ flaky test(s)
github.com/e2b-dev/infra/tests/integration/internal/tests/envd::TestCommandKillNextApp

Flake rate in main: 48.02% (Passed 512 times, Failed 473 times)

Stack Traces | 57s run time
=== RUN   TestCommandKillNextApp
=== PAUSE TestCommandKillNextApp
=== CONT  TestCommandKillNextApp
    process_test.go:28: Command [npx] output: event:{start:{pid:1263}}
Executing command python in sandbox i7aro5p7v3mqdy75jheuj
    process_test.go:28: Command [npx] output: event:{data:{stderr:"npm"}}
    process_test.go:28: Command [npx] output: event:{data:{stderr:" WARN exec The following package was not found and will be installed: create-next-app@16.2.6\n"}}
    process_test.go:28: Command [npx] output: event:{data:{stdout:"Creating a new Next.js app in .../home/user/nextapp.\n"}}
    process_test.go:28: Command [npx] output: event:{data:{stdout:"\nUsing npm.\n\nInitializing project with template: app-tw \n\n"}}
    process_test.go:28: Command [npx] output: event:{data:{stdout:"\nInstalling dependencies:\n"}}
    process_test.go:28: Command [npx] output: event:{data:{stdout:"- next\n"}}
    process_test.go:28: Command [npx] output: event:{data:{stdout:"- react\n"}}
    process_test.go:28: Command [npx] output: event:{data:{stdout:"- react-dom\n\nInstalling devDependencies:\n- @tailwindcss/postcss\n- @types/node\n- @types/react\n- @types/react-dom\n- eslint\n"}}
    process_test.go:28: Command [npx] output: event:{data:{stdout:"- eslint-config-next\n- tailwindcss\n- typescript\n\n"}}
    process_test.go:28: Command [npx] output: event:{data:{stderr:"npm ERR! code ECONNRESET\n"}}
    process_test.go:28: Command [npx] output: event:{data:{stderr:"npm ERR! "}}
    process_test.go:28: Command [npx] output: event:{data:{stderr:"errno ECONNRESET\n"}}
    process_test.go:28: Command [npx] output: event:{data:{stderr:"npm ERR! network Invalid response body while trying to fetch https://registry.npmjs.org/@typescript-eslint%2ftypescript-estree: aborted\nnpm ERR! network This is a problem related to network connectivity.\nnpm ERR! network In most cases you are behind a proxy or have bad network settings.\nnpm ERR! network \nnpm ERR! network If you are behind a proxy, please make sure that the\nnpm ERR! network 'proxy' config is set properly.  See: 'npm help config'\n\nnpm ERR! A complete log of this run can be found in: .../home/user/.npm/_logs/2026-05-22T10_06_49_507Z-debug-0.log\n"}}
    process_test.go:28: Command [npx] output: event:{data:{stdout:"\nAborting installation.\n"}}
    process_test.go:28: Command [npx] output: event:{data:{stdout:"  npm install has failed.\n"}}
    process_test.go:28: Command [npx] output: event:{data:{stdout:"\n"}}
    process_test.go:28: Command [npx] output: event:{data:{stderr:"npm notice"}}
    process_test.go:28: Command [npx] output: event:{data:{stderr:" \nnpm "}}
    process_test.go:28: Command [npx] output: event:{data:{stderr:"notice New major version of npm available! 10.1.0 -> 11.15.0\nnpm notice Changelog: <https://github..../releases/tag/v11.15.0>\nnpm notice Run `npm install -g npm@11.15.0` to update!\nnpm notice \n"}}
    process_test.go:28: Command [npx] output: event:{end:{exited:true status:"exit status 0"}}
    process_test.go:28: Command [npx] completed successfully in sandbox i02nxjcwcam182jif1wme
    process_test.go:55: dev: event:{start:{pid:1326}}
    process_test.go:55: dev: event:{data:{stdout:"\n> nextapp@0.1.0 dev\n> next dev\n\n"}}
    process_test.go:55: dev: event:{data:{stderr:"sh: 1: next: not found\n"}}
    process_test.go:55: dev: event:{end:{exit_code:127 exited:true status:"exit status 127" error:"exit status 127"}}
    process_test.go:79: 
        	Error Trace:	.../tests/envd/process_test.go:79
        	Error:      	"[]" should have 1 item(s), but has 0
        	Test:       	TestCommandKillNextApp
        	Messages:   	Expected one process (next dev) running
--- FAIL: TestCommandKillNextApp (56.97s)
github.com/e2b-dev/infra/tests/integration/internal/tests/orchestrator::TestSandboxMemoryIntegrity

Flake rate in main: 61.50% (Passed 517 times, Failed 826 times)

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

Flake rate in main: 61.74% (Passed 507 times, Failed 818 times)

Stack Traces | 131s 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:1254}}
Executing command bash in sandbox iuzar4z4iw3ldezg2sax1 (user: root)
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stdout:"Total memory: 985 MB\nUsed memory before tmpfs mount: 191 MB\nFree memory before tmpfs mount: 793 MB\nMemory to use in integrity test (80% of free, min 64MB): 634 MB\n"}}
Executing command bash in sandbox iuzar4z4iw3ldezg2sax1 (user: root)
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"634+0 records in\n634+0 records out\n664797184 bytes (665 MB, 634 MiB) copied, 3.3224 s, 200 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=634\"\n\tUser time (seconds): 0.00\n\tSystem time (seconds): 3.29\n\tPercent of CPU this job got: 99%\n\tElapsed (wall clock) time (h:mm:ss or m:ss): 0:03.32\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): 2708\n\tAverage resident set size (kbytes): 0\n\tMajor (requiring I/O) page faults: 2\n\tMinor (reclaiming a frame) page faults: 344\n\tVoluntary context switches: 3\n\tInvoluntary context switches: 13\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: 830 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 iyqwbwza2c139z4ftoqos
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
    sandbox_memory_integrity_test.go:80: Command [bash] output: event:{start:{pid:1270}}
    sandbox_memory_integrity_test.go:80: Command [bash] output: event:{data:{stdout:"2cf01b7100f49d4d496e9cc35d9d3c793bdc9eefa1ac779b47b632a9a9240314\n"}}
    sandbox_memory_integrity_test.go:80: Command [bash] output: event:{end:{exited:true status:"exit status 0"}}
    sandbox_memory_integrity_test.go:80: Command [bash] completed successfully in sandbox iyqwbwza2c139z4ftoqos
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
    sandbox_memory_integrity_test.go:80: Command [bash] output: event:{start:{pid:1273}}
    sandbox_memory_integrity_test.go:80: Command [bash] output: event:{data:{stdout:"2cf01b7100f49d4d496e9cc35d9d3c793bdc9eefa1ac779b47b632a9a9240314\n"}}
    sandbox_memory_integrity_test.go:80: Command [bash] output: event:{end:{exited:true status:"exit status 0"}}
    sandbox_memory_integrity_test.go:80: Command [bash] completed successfully in sandbox iyqwbwza2c139z4ftoqos
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
    sandbox_memory_integrity_test.go:80: Command [bash] output: event:{start:{pid:1276}}
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
Executing command bash in sandbox iyqwbwza2c139z4ftoqos (user: root)
    sandbox_memory_integrity_test.go:110: 
        	Error Trace:	.../tests/orchestrator/sandbox_memory_integrity_test.go:81
        	            				.../hostedtoolcache/go/1.26.3.../src/runtime/asm_amd64.s:1771
        	Error:      	Received unexpected error:
        	            	failed to execute command bash in sandbox iyqwbwza2c139z4ftoqos: unavailable: HTTP status 502 Bad Gateway
    sandbox_memory_integrity_test.go:110: 
        	Error Trace:	.../tests/orchestrator/sandbox_memory_integrity_test.go:78
        	            				.../tests/orchestrator/sandbox_memory_integrity_test.go:110
        	Error:      	Condition never satisfied
        	Test:       	TestSandboxMemoryIntegrity/tmpfs_hash
--- FAIL: TestSandboxMemoryIntegrity/tmpfs_hash (130.62s)

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

@jakubno jakubno merged commit 10085a1 into main May 23, 2026
55 checks passed
@jakubno jakubno deleted the fix/template-tag-error-reporting branch May 23, 2026 03:36
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