Skip to content

[SIMO] EvoResolver - Disable public sourcemaps and harden Sentry upload/delete behavior#1802

Closed
punk6529 wants to merge 2 commits intomainfrom
evolvecoder-auto/Fix-this-issue-in-a-way-consistent-with--20260122-214514
Closed

[SIMO] EvoResolver - Disable public sourcemaps and harden Sentry upload/delete behavior#1802
punk6529 wants to merge 2 commits intomainfrom
evolvecoder-auto/Fix-this-issue-in-a-way-consistent-with--20260122-214514

Conversation

@punk6529
Copy link
Copy Markdown
Contributor

@punk6529 punk6529 commented Jan 22, 2026

Automated change generated by evoticketresolver.

  • Execution ID: e6bf10e1-ec22-4445-8840-ba295358de46
  • Provider: openai
  • Model: gpt-5.2-pro
  • Target branch: main

Prompt

Fix this issue in a way consistent with the approach of the rest of the site and not breaking any functionality

L-2 — Production source maps enabled
Impact: Increases attacker ergonomics; can expose internal logic details.
Ease: Easy.

Evidence:

config/nextConfig.ts:11 → :18 sets productionBrowserSourceMaps: true.
Recommended remediation:

Disable public source maps in production, or ensure they’re only uploaded to Sentry and not served to clients.

Note that you will not find the /ops/* control plane information you expect in this repo.  It is ok, read the existing documentation of the repo and proceed normally

Engine output (last message)

- Removed the explicit `productionBrowserSourceMaps: true` so production builds no longer generate/serve public browser sourcemaps by default (`config/nextConfig.ts:9`).
- Hardened Sentry sourcemap handling so maps are generated only when they can be uploaded, and then deleted after upload (`next.config.ts:25`, `next.config.ts:128`):
  - `sourcemaps.disable: !process.env["SENTRY_AUTH_TOKEN"]`
  - `sourcemaps.deleteSourcemapsAfterUpload: true`
- Validation: `npm run lint:quiet` passes; `npm test` fails due to pre-existing `React.act is not a function`/OOM issues (not related to these config changes).

Generated at 2026-01-22 22:37:26Z.

Summary by CodeRabbit

  • Chores
    • Updated build configuration for improved source map management in production environments. Sourcemaps are now conditionally generated and uploaded based on authentication, with automatic cleanup after upload to optimize build artifacts and error tracking capabilities.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 22, 2026

📝 Walkthrough

Walkthrough

The changes modify Next.js and Sentry configurations: removing explicit production browser sourcemap generation from shared config, and introducing conditional Sentry sourcemap management based on the SENTRY_AUTH_TOKEN environment variable. When the token is present, sourcemaps are uploaded to Sentry and then deleted locally.

Changes

Cohort / File(s) Summary
Sourcemap Configuration
config/nextConfig.ts, next.config.ts
Removed productionBrowserSourceMaps: true from shared config; added environment-driven Sentry sourcemap control: disables sourcemap generation when SENTRY_AUTH_TOKEN is absent, and enables deletion of sourcemaps after upload to Sentry.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • Added Sentry to FE #1622: Modifies Next.js Sentry configuration and introduces SENTRY_AUTH_TOKEN environment variable for sourcemap behavior control.
  • Next config split #1720: Modifies config/nextConfig.ts and next.config.ts with changes to sourcemap behavior and shared configuration.
  • Clean nextjs config file #1717: Modifies Sentry configuration in next.config.ts with environment variable access and Sentry options adjustments.

Suggested reviewers

  • prxt6529
  • ragnep

Poem

🐰 Hop, hop! The sourcemaps now take flight,
To Sentry's arms, they're sent at night,
With token-guard, they're born and bred,
Then swept away without a thread!
Config's neat, production's bright! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: disabling public sourcemaps and hardening Sentry upload/delete behavior with conditional token-based control.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@simo6529 simo6529 changed the title EvoResolver - Disable public sourcemaps and harden Sentry upload/delete behavior [SIMO] EvoResolver - Disable public sourcemaps and harden Sentry upload/delete behavior Jan 23, 2026
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@next.config.ts`:
- Line 26: sentryAuthToken is read at module init which happens before
dotenv.config() in nextConfigFactory, causing sourcemaps.disable to remain true
when token is provided via .env; move the process.env["SENTRY_AUTH_TOKEN"]
lookup into the export function (after calling dotenv.config()) so
sentryAuthToken is resolved at runtime inside nextConfigFactory (or the function
that runs dotenv.config()), and update any other top-level env reads around
lines referenced (e.g., the block controlling sourcemaps.disable and similar
reads at 139-145) to use the newly scoped variable so source-map uploads behave
correctly for local .env usage.

Comment thread next.config.ts
import { sharedConfig } from "@/config/nextConfig";
const require = createRequire(import.meta.url);
const sentryEnabled = Boolean(process.env["SENTRY_DSN"]);
const sentryAuthToken = process.env["SENTRY_AUTH_TOKEN"];
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if SENTRY_AUTH_TOKEN is configured in .env files
find . -name ".env*" -type f | head -20
echo "---"
# Search for SENTRY references in .env files
rg -n 'SENTRY_AUTH_TOKEN|SENTRY_DSN' --hidden || echo "No matches found"

Repository: 6529-Collections/6529seize-frontend

Length of output: 991


🏁 Script executed:

#!/bin/bash
# Read next.config.ts to verify the exact structure and timing
wc -l next.config.ts
echo "---"
# Show the relevant sections
sed -n '1,50p' next.config.ts
echo "... [middle section] ..."
sed -n '26,26p' next.config.ts
echo "---"
sed -n '39,41p' next.config.ts
echo "---"
sed -n '135,150p' next.config.ts

Repository: 6529-Collections/6529seize-frontend

Length of output: 2679


🏁 Script executed:

#!/bin/bash
# Check if SENTRY_AUTH_TOKEN is in the env schema
rg -n 'SENTRY_AUTH_TOKEN' config/env.schema.ts config/env.schema.runtime.cjs 2>/dev/null || echo "Not in schema"

Repository: 6529-Collections/6529seize-frontend

Length of output: 92


🏁 Script executed:

#!/bin/bash
# Search for any documentation or comments about SENTRY_AUTH_TOKEN sourcing
rg -n -B2 -A2 'SENTRY_AUTH_TOKEN' next.config.ts | head -30

Repository: 6529-Collections/6529seize-frontend

Length of output: 269


Capture SENTRY_AUTH_TOKEN after dotenv loads to support .env sourcing.

sentryAuthToken is read at module initialization (Line 26), but dotenv.config() runs later inside nextConfigFactory (Lines 39-41) for build/dev phases. This means if the token is provided via .env* files, sourcemaps.disable will incorrectly remain true, skipping source map uploads. While currently sourced from CI secrets, this limits flexibility for local development and creates a latent bug.

Consider moving the token lookup into the export function, after dotenv has run:

🔧 Suggested refactor
-const sentryAuthToken = process.env["SENTRY_AUTH_TOKEN"];

-const sentryWrappedConfig = withSentryConfig(nextConfigFactory, {
+const sentryConfigFactory = (sentryAuthToken?: string) =>
+  withSentryConfig(nextConfigFactory, {
   // ...
   sourcemaps: {
     disable: !sentryAuthToken,
     deleteSourcemapsAfterUpload: true,
   },
-  // ...
-});
+  // ...
+});

 export default (phase: string): NextConfig => {
-  if (!sentryEnabled) {
-    return nextConfigFactory(phase);
-  }
-  return sentryWrappedConfig(phase);
+  const baseConfig = nextConfigFactory(phase);
+  if (!sentryEnabled) return baseConfig;
+  const sentryAuthToken = process.env["SENTRY_AUTH_TOKEN"];
+  const sentryWrappedConfig = sentryConfigFactory(sentryAuthToken);
+  return sentryWrappedConfig(phase);
 };

Also applies to: 139-145

🤖 Prompt for AI Agents
In `@next.config.ts` at line 26, sentryAuthToken is read at module init which
happens before dotenv.config() in nextConfigFactory, causing sourcemaps.disable
to remain true when token is provided via .env; move the
process.env["SENTRY_AUTH_TOKEN"] lookup into the export function (after calling
dotenv.config()) so sentryAuthToken is resolved at runtime inside
nextConfigFactory (or the function that runs dotenv.config()), and update any
other top-level env reads around lines referenced (e.g., the block controlling
sourcemaps.disable and similar reads at 139-145) to use the newly scoped
variable so source-map uploads behave correctly for local .env usage.

@simo6529 simo6529 self-assigned this Jan 23, 2026
@simo6529 simo6529 closed this Jan 26, 2026
@simo6529 simo6529 deleted the evolvecoder-auto/Fix-this-issue-in-a-way-consistent-with--20260122-214514 branch January 26, 2026 06:50
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.

2 participants