Skip to content

LINK-2574: Migrate linkedregistrations-ui from Yarn to pnpm and add runtime env injection#297

Merged
jorilindell merged 6 commits into
mainfrom
LINK-2574-pnpm-migration
Jun 8, 2026
Merged

LINK-2574: Migrate linkedregistrations-ui from Yarn to pnpm and add runtime env injection#297
jorilindell merged 6 commits into
mainfrom
LINK-2574-pnpm-migration

Conversation

@jorilindell

@jorilindell jorilindell commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR migrates the project tooling from Yarn to pnpm as the primary package manager.
It also introduces runtime environment variable injection so environment-specific values can be provided at runtime without rebuilding the app.

What Changed

  • Replaced Yarn-based workflows with pnpm in project tooling and CI
  • Added pnpm lockfile and workspace configuration
  • Removed Yarn lockfile
  • Updated Node/tooling related configs for compatibility
  • Added runtime env injection script and startup wiring
  • Updated runtime config utilities to read injected/public environment values
  • Added and updated tests for environment and runtime config handling
  • Updated docs and pipeline-related configuration
  • Upgraded Node to version 24

Related Azure PR:
https://dev.azure.com/City-of-Helsinki/linkedevents/_git/linkedevents-pipelines/pullrequest/16079

Refs: LINK-2574

Summary by CodeRabbit

  • Chores

    • Migrated from Yarn to pnpm and raised Node requirement to v24; updated Docker, CI, IDE, and tooling accordingly.
    • Updated ignore rules and commit hook to reflect pnpm usage.
  • New Features

    • Loads runtime public environment into the app at startup and adds a container entrypoint to generate that runtime env.
    • Sentry/analytics read runtime env values for configuration.
  • Documentation

    • README updated for pnpm and Node 24.
  • Tests

    • Tests adapted for new runtime env handling and improved isolation.

@jorilindell jorilindell force-pushed the LINK-2574-pnpm-migration branch 4 times, most recently from b2fb5db to 19a81c5 Compare June 2, 2026 00:13
@azure-pipelines

Copy link
Copy Markdown

LINKEDREGISTRATIONS-UI branch is deployed to platta: https://linkedregistrations-pr297-ui.dev.hel.ninja 🚀🚀🚀

@azure-pipelines

Copy link
Copy Markdown

e2e tests result is failed for https://linkedregistrations-pr297-ui.dev.hel.ninja 😿💢💥💥

@jorilindell jorilindell force-pushed the LINK-2574-pnpm-migration branch from 19a81c5 to 18755ce Compare June 2, 2026 00:36
@azure-pipelines

Copy link
Copy Markdown

LINKEDREGISTRATIONS-UI branch is deployed to platta: https://linkedregistrations-pr297-ui.dev.hel.ninja 🚀🚀🚀

@azure-pipelines

Copy link
Copy Markdown

e2e tests result is success for https://linkedregistrations-pr297-ui.dev.hel.ninja 😆🎉🎉🎉

@jorilindell jorilindell force-pushed the LINK-2574-pnpm-migration branch 3 times, most recently from 164d1df to cae7db7 Compare June 2, 2026 06:58
@azure-pipelines

Copy link
Copy Markdown

LINKEDREGISTRATIONS-UI branch is deployed to platta: https://linkedregistrations-pr297-ui.dev.hel.ninja 🚀🚀🚀

@azure-pipelines

Copy link
Copy Markdown

e2e tests result is success for https://linkedregistrations-pr297-ui.dev.hel.ninja 😆🎉🎉🎉

@jorilindell jorilindell force-pushed the LINK-2574-pnpm-migration branch from cae7db7 to 3084f50 Compare June 2, 2026 09:55
@azure-pipelines

Copy link
Copy Markdown

LINKEDREGISTRATIONS-UI branch is deployed to platta: https://linkedregistrations-pr297-ui.dev.hel.ninja 🚀🚀🚀

@azure-pipelines

Copy link
Copy Markdown

e2e tests result is success for https://linkedregistrations-pr297-ui.dev.hel.ninja 😆🎉🎉🎉

@jorilindell jorilindell force-pushed the LINK-2574-pnpm-migration branch from 3084f50 to 2247f6f Compare June 2, 2026 11:37
@azure-pipelines

Copy link
Copy Markdown

LINKEDREGISTRATIONS-UI branch is deployed to platta: https://linkedregistrations-pr297-ui.dev.hel.ninja 🚀🚀🚀

@azure-pipelines

Copy link
Copy Markdown

e2e tests result is success for https://linkedregistrations-pr297-ui.dev.hel.ninja 😆🎉🎉🎉

@jorilindell jorilindell force-pushed the LINK-2574-pnpm-migration branch from 2247f6f to 0c72e81 Compare June 3, 2026 08:05
@azure-pipelines

Copy link
Copy Markdown

LINKEDREGISTRATIONS-UI branch is deployed to platta: https://linkedregistrations-pr297-ui.dev.hel.ninja 🚀🚀🚀

@azure-pipelines

Copy link
Copy Markdown

e2e tests result is success for https://linkedregistrations-pr297-ui.dev.hel.ninja 😆🎉🎉🎉

@jorilindell jorilindell force-pushed the LINK-2574-pnpm-migration branch from 0c72e81 to 70e19af Compare June 3, 2026 10:15
@jorilindell jorilindell marked this pull request as ready for review June 3, 2026 10:23
@jorilindell jorilindell requested a review from a team as a code owner June 3, 2026 10:23
Comment thread src/utils/getEnvValue.ts
@jorilindell jorilindell force-pushed the LINK-2574-pnpm-migration branch from 70e19af to 469f275 Compare June 3, 2026 10:39
@azure-pipelines

Copy link
Copy Markdown

LINKEDREGISTRATIONS-UI branch is deployed to platta: https://linkedregistrations-pr297-ui.dev.hel.ninja 🚀🚀🚀

@azure-pipelines

Copy link
Copy Markdown

e2e tests result is failed for https://linkedregistrations-pr297-ui.dev.hel.ninja 😿💢💥💥

@jorilindell

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 15e51a6f-c65a-4f7d-bdde-90317c305a10

📥 Commits

Reviewing files that changed from the base of the PR and between 42a1ef8 and 57b80bd.

📒 Files selected for processing (25)
  • .dockerignore
  • .env
  • .gitignore
  • Dockerfile
  • README.md
  • package.json
  • scripts/docker-entrypoint.sh
  • scripts/env.sh
  • scripts/update-runtime-env.js
  • sonar-project.properties
  • src/domain/app/layout/pageLayout/PageLayout.tsx
  • src/domain/registration/__tests__/utils.test.ts
  • src/domain/registration/utils.ts
  • src/instrumentation-client.ts
  • src/pages/_document.tsx
  • src/pages/api/readiness.ts
  • src/setupTests.ts
  • src/types/runtime-env.d.ts
  • src/utils/__tests__/getEnvValue.test.ts
  • src/utils/__tests__/getPublicRuntimeConfig.test.ts
  • src/utils/__tests__/getServerRuntimeConfig.test.ts
  • src/utils/featureFlags.ts
  • src/utils/getEnvValue.ts
  • src/utils/getPublicRuntimeConfig.ts
  • vitest.config.ts
✅ Files skipped from review due to trivial changes (4)
  • .gitignore
  • sonar-project.properties
  • .dockerignore
  • README.md
🚧 Files skipped from review as they are similar to previous changes (18)
  • src/utils/getPublicRuntimeConfig.ts
  • vitest.config.ts
  • src/utils/featureFlags.ts
  • scripts/docker-entrypoint.sh
  • src/utils/tests/getServerRuntimeConfig.test.ts
  • scripts/env.sh
  • src/pages/api/readiness.ts
  • src/domain/app/layout/pageLayout/PageLayout.tsx
  • src/setupTests.ts
  • src/utils/tests/getPublicRuntimeConfig.test.ts
  • src/domain/registration/utils.ts
  • src/types/runtime-env.d.ts
  • src/domain/registration/tests/utils.test.ts
  • src/instrumentation-client.ts
  • package.json
  • src/utils/tests/getEnvValue.test.ts
  • scripts/update-runtime-env.js
  • Dockerfile

📝 Walkthrough

Walkthrough

Migrates tooling from Yarn to pnpm on Node 24, introduces runtime env bundle generation (public/env-config.js) and a getEnvValue() accessor, and applies the changes across Docker, CI, app code, tests, and coverage settings.

Changes

Yarn to pnpm Migration and Runtime Environment System

Layer / File(s) Summary
Tooling upgrade: pnpm & Node 24
.husky/commit-msg, .nvmrc, .vscode/launch.json, .github/workflows/ci.yml, package.json, README.md
Switch developer tooling, CI, and docs from Yarn to pnpm; bump Node requirement to 24; update scripts and package metadata.
Docker infra and build system
.dockerignore, Dockerfile, scripts/docker-entrypoint.sh
Dockerfile updated for nodejs-24 and pnpm multi-stage build, new ENTRYPOINT/CMD, symlink and permissions for env-config, and .dockerignore now includes scripts and pnpm manifests.
Runtime env generation & workspace policy
pnpm-workspace.yaml, scripts/update-runtime-env.js, scripts/env.sh, scripts/docker-entrypoint.sh
Add scripts to generate public/env-config.js from NEXT_PUBLIC_* envs, shell wrappers to invoke generation, and workspace overrides/allowBuilds policies; exclude scripts from coverage.
VCS ignores and .env edits
.dockerignore, .gitignore, .env
Include scripts and pnpm manifests in Docker context, ignore generated public/env-config.js files, and add NEXT_PUBLIC_SENTRY_* and NEXT_PUBLIC_USE_IMAGE_PROXY entries in .env.
Runtime accessor, types, and document injection
src/utils/getEnvValue.ts, src/types/runtime-env.d.ts, src/pages/_document.tsx, src/setupTests.ts
New getEnvValue() reads normalized values from window._env_ or falls back to process.env; add Window typing; inject /env-config.js before interactive content; test setup drops next/config wiring.
Config accessors, mocks, and tests
src/utils/getPublicRuntimeConfig.ts, src/utils/getServerRuntimeConfig.ts, src/utils/mockNextJsConfig.ts, src/utils/__tests__/*
Switch config accessors to read from env/getEnvValue, update mock helper to stub env vars with vi.stubEnv, and add/adjust tests for getEnvValue and runtime config behavior.
Application-level integration and tests
src/instrumentation-client.ts, src/pages/api/readiness.ts, src/domain/registration/*, src/domain/app/layout/pageLayout/PageLayout.tsx, src/utils/featureFlags.ts, domain tests
Update Sentry, Matomo, readiness API, registration path builder, feature flags, and UI tests to consume env via getEnvValue and the generated runtime bundle; adjust modal tests for stability.
Coverage exclusion updates
sonar-project.properties, vitest.config.ts
Exclude scripts/** from SonarQube and Vitest coverage instrumentation.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I stitched the env into a tiny jar,
pnpm hums, Node climbs the bar,
window.env whispers keys at runtime,
Docker listens, scripts chime in time,
A rabbit hops with a config cheer—hooray!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the two main objectives: migrating from Yarn to pnpm and adding runtime environment variable injection, matching the substantial changes across the codebase.
Description check ✅ Passed The description provides a clear summary, lists key changes, and references the related issue/PR, though it deviates from the repository's template structure by omitting standard sections like Issues, Testing, and Screenshots.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch LINK-2574-pnpm-migration

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🧹 Nitpick comments (2)
scripts/update-runtime-env.js (1)

16-46: ⚡ Quick win

Consider using a standard .env parser library.

The custom parsing implementation doesn't handle several .env file edge cases such as multi-line values, escaped characters, variable expansion, or mismatched quotes. While this may be sufficient for current needs, using a well-tested library like dotenv would provide more robust parsing and future-proof the implementation.

📚 Recommended refactor using dotenv

Install dotenv as a dependency, then simplify the parsing:

+const dotenv = require('dotenv');
 const fs = require('fs');
 const path = require('path');

-const parseEnvContent = (content) => {
-  const parsed = {};
-
-  content.split(/\r?\n/).forEach((line) => {
-    const trimmed = line.trim();
-
-    if (!trimmed || trimmed.startsWith('#')) {
-      return;
-    }
-
-    const separatorIndex = trimmed.indexOf('=');
-
-    if (separatorIndex < 0) {
-      return;
-    }
-
-    const key = trimmed.slice(0, separatorIndex).trim();
-    let value = trimmed.slice(separatorIndex + 1).trim();
-
-    if (
-      (value.startsWith('"') && value.endsWith('"')) ||
-      (value.startsWith("'") && value.endsWith("'"))
-    ) {
-      value = value.slice(1, -1);
-    }
-
-    parsed[key] = value;
-  });
-
-  return parsed;
-};
-
 const loadEnvFromFiles = () => {
   const env = {};

   envFiles.forEach((fileName) => {
     const filePath = path.resolve(envDir, fileName);
     if (!fs.existsSync(filePath)) {
       return;
     }

-    const parsed = parseEnvContent(fs.readFileSync(filePath, 'utf8'));
+    const parsed = dotenv.parse(fs.readFileSync(filePath, 'utf8'));
     Object.assign(env, parsed);
   });

   return env;
 };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/update-runtime-env.js` around lines 16 - 46, The custom
parseEnvContent function is brittle and should be replaced with a standard .env
parser; remove or stop using parseEnvContent and instead call
dotenv.parse(content) (after adding dotenv to dependencies) to build the parsed
object, or use dotenv.config() if reading from a file; update any callers in
scripts/update-runtime-env.js to use the object returned by dotenv.parse and
keep existing handling of the parsed keys.
pnpm-workspace.yaml (1)

4-5: 💤 Low value

Clarify the comment or remove the configuration.

The comment states "Don't warn about ignored build scripts," but the array is empty, meaning no build scripts are actually ignored. Either remove this configuration if unused, or update the comment to reflect that this is a placeholder for future use.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pnpm-workspace.yaml` around lines 4 - 5, The comment above
ignoredBuiltDependencies is misleading because the array is empty; either remove
the ignoredBuiltDependencies: [] entry entirely if it's unused, or update the
comment to indicate it is a placeholder (e.g., "Placeholder for ignored build
scripts — currently empty") so the meaning matches the empty array; locate the
ignoredBuiltDependencies key in the pnpm-workspace.yaml and apply one of those
two changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yml:
- Around line 12-13: Update the reusable workflow reference to pin the commit
SHA instead of using `@main` (use the provided SHA
4de6bb1b0d7beb5d719dcfaa3a26613dac905e2a) and remove the broad secrets: inherit;
instead pass only the explicitly required secret declared by the called workflow
(SONAR_TOKEN) by mapping it from this repository's secrets (replace the secrets:
inherit block with a secrets block that forwards SONAR_TOKEN via the caller's
secrets).

In `@Dockerfile`:
- Around line 74-80: The files are copied with group "nodejs" which prevents a
random UID with gid 0 from using the intended group write path; update the
COPY/COPY --chown usage and permissions so group ID 0 owns or can write the
runtime assets: replace the COPY lines that use "--chown=default:nodejs" (the
two COPY --from=builder entries for /app/public and /app/scripts) with either no
--chown or with "--chown=default:0", then adjust the RUN step to explicitly set
group ownership and group-writable bits (e.g., use chgrp -R 0 /app/public
/app/scripts && chmod -R g+rwX /app/public /app/scripts) before
removing/creating the env-config.js symlink so a process running with an
arbitrary UID but gid 0 can write /tmp/env-config.js via the group permissions.

In `@README.md`:
- Line 188: The README references a pnpm script "test:debug" that doesn't exist
in package.json; either add a "test:debug" script entry to package.json (under
the "scripts" section) that runs the intended debug test command, or update
README.md to reference an existing script (e.g., "test" or "test:watch") and
ensure the script name in README matches the exact key in package.json
("test:debug"). Make the change so the README and package.json scripts are
consistent.
- Line 67: Update the development command text that currently reads "Run `pnpm i
&& pnpm start`" to use the development workflow command `pnpm dev` (for example:
"Run `pnpm i && pnpm dev`" or simply "pnpm dev"), ensuring the "local
development" section and any occurrences of `pnpm start` meant for dev are
changed to `pnpm dev` to match the stated workflow.

In `@src/instrumentation-client.ts`:
- Around line 32-33: tracePropagationTargets is being built from
getEnvValue('NEXT_PUBLIC_SENTRY_TRACE_PROPAGATION_TARGETS') and currently uses
(... || '').split(',') which yields [''] when the env is empty and causes
wildcard propagation; change the construction of tracePropagationTargets to
split, trim each entry and filter out empty strings (e.g. map trim then
filter(Boolean)) so an empty or unset env produces an empty array rather than
['']; update the expression that sets tracePropagationTargets (referencing
getEnvValue and the NEXT_PUBLIC_SENTRY_TRACE_PROPAGATION_TARGETS env)
accordingly.

In `@src/utils/__tests__/getServerRuntimeConfig.test.ts`:
- Around line 16-25: The tests in the getServerRuntimeConfig suite call
vi.stubEnv(...) but never restore environment, causing leaks between tests; add
cleanup by calling vi.unstubAllEnvs() in an afterEach (or beforeEach) for the
suite that contains the tests in
src/utils/__tests__/getServerRuntimeConfig.test.ts so each test resets env
state—locate the test suite/block where getServerRuntimeConfig tests are defined
and add a teardown (afterEach(() => vi.unstubAllEnvs())) to ensure stubbed env
vars are cleared between tests.

In `@src/utils/getEnvValue.ts`:
- Around line 20-23: The current getEnvValue function repeatedly calls
console.warn when globalThis.window._env_ is undefined, causing console spam;
modify getEnvValue to emit that warning only once by introducing a module-scoped
boolean flag (e.g., envWarningLogged) checked before calling console.warn, set
the flag to true after the first warning, and keep all existing message text and
condition logic around globalThis.window._env_ so subsequent calls skip the warn
path; ensure the flag is defined outside the getEnvValue function so it persists
across invocations.

---

Nitpick comments:
In `@pnpm-workspace.yaml`:
- Around line 4-5: The comment above ignoredBuiltDependencies is misleading
because the array is empty; either remove the ignoredBuiltDependencies: [] entry
entirely if it's unused, or update the comment to indicate it is a placeholder
(e.g., "Placeholder for ignored build scripts — currently empty") so the meaning
matches the empty array; locate the ignoredBuiltDependencies key in the
pnpm-workspace.yaml and apply one of those two changes.

In `@scripts/update-runtime-env.js`:
- Around line 16-46: The custom parseEnvContent function is brittle and should
be replaced with a standard .env parser; remove or stop using parseEnvContent
and instead call dotenv.parse(content) (after adding dotenv to dependencies) to
build the parsed object, or use dotenv.config() if reading from a file; update
any callers in scripts/update-runtime-env.js to use the object returned by
dotenv.parse and keep existing handling of the parsed keys.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e0977669-f6f8-4815-a756-6e72967311ff

📥 Commits

Reviewing files that changed from the base of the PR and between b4019fd and 469f275.

⛔ Files ignored due to path filters (2)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (35)
  • .dockerignore
  • .env
  • .github/workflows/ci.yml
  • .gitignore
  • .husky/commit-msg
  • .nvmrc
  • .vscode/launch.json
  • Dockerfile
  • README.md
  • next.config.js
  • package.json
  • pnpm-workspace.yaml
  • scripts/docker-entrypoint.sh
  • scripts/env.sh
  • scripts/update-runtime-env.js
  • sonar-project.properties
  • src/domain/app/layout/pageLayout/PageLayout.tsx
  • src/domain/registration/__tests__/utils.test.ts
  • src/domain/registration/utils.ts
  • src/domain/signupGroup/participantAmountSelector/__tests__/ParticipantAmountSelector.test.tsx
  • src/domain/signupGroup/reservationTimer/__tests__/ReservationTimer.test.tsx
  • src/instrumentation-client.ts
  • src/pages/_document.tsx
  • src/pages/api/readiness.ts
  • src/setupTests.ts
  • src/types/runtime-env.d.ts
  • src/utils/__tests__/getEnvValue.test.ts
  • src/utils/__tests__/getPublicRuntimeConfig.test.ts
  • src/utils/__tests__/getServerRuntimeConfig.test.ts
  • src/utils/featureFlags.ts
  • src/utils/getEnvValue.ts
  • src/utils/getPublicRuntimeConfig.ts
  • src/utils/getServerRuntimeConfig.ts
  • src/utils/mockNextJsConfig.ts
  • vitest.config.ts

Comment thread .github/workflows/ci.yml Outdated
Comment thread Dockerfile Outdated
Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread src/instrumentation-client.ts Outdated
Comment thread src/utils/__tests__/getServerRuntimeConfig.test.ts
Comment thread src/utils/getEnvValue.ts Outdated
- switch local scripts, VS Code launch config, and Husky commit-msg
  hook to pnpm
- update Dockerfile to install and use pnpm via Corepack
- replace Yarn lockfile with pnpm lockfile and add pnpm workspace
  config
- update README commands and prerequisites from Yarn to pnpm
- add packageManager and pnpm engine constraints in package.json
- move dependency constraints from resolutions to pnpm overrides
- bump Next.js patch version and add missing Node types dependency

Refs: LINK-2574
- update .nvmrc to v24.14.1
- update CI workflow Node version to 24.x
- bump Docker base images from nodejs-22 to nodejs-24
- update package.json engine constraint to >=24.14.1

Refs: LINK-2574
- remove Next.js runtimeConfig usage in app config and test setup
- update runtime config helpers to read values from process.env
- update tests to stub required env vars with vi.stubEnv
- map mock config keys to environment variable names

Refs: LINK-2574
Playwright install could hang on Node 24.
Upgrade Playwright to 1.60.0 and refresh lockfile entries.
This version includes the fix for the install issue.

Refs: LINK-2573
@jorilindell jorilindell force-pushed the LINK-2574-pnpm-migration branch 2 times, most recently from 2f15820 to 42a1ef8 Compare June 4, 2026 10:52

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@package.json`:
- Line 13: The "start" npm script currently runs "pnpm update-runtime-env"
before "next start" without NODE_ENV=production, which can cause runtime config
to be generated as development; update the "start" script (the package.json
"start" entry) so NODE_ENV=production is set for the whole command that runs
update-runtime-env and next start (e.g., prefix the command with
NODE_ENV=production or use cross-env if cross-platform support is required) to
ensure runtime env generation and Next.js run in production mode.

In `@src/utils/__tests__/getEnvValue.test.ts`:
- Around line 15-21: The test file defines an unused helper function
unsetRuntimeEnv which triggers no-unused-vars; remove the entire unsetRuntimeEnv
function declaration (the Object.defineProperty call that sets _env_ to
undefined) from src/utils/__tests__/getEnvValue.test.ts and any
references/imports for windowWithEnv only if they become unused after removal so
the linter no longer flags an unused variable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0bb82c4a-c43c-4497-8aa8-0bd4131a2aed

📥 Commits

Reviewing files that changed from the base of the PR and between 469f275 and 2f15820.

⛔ Files ignored due to path filters (2)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (35)
  • .dockerignore
  • .env
  • .github/workflows/ci.yml
  • .gitignore
  • .husky/commit-msg
  • .nvmrc
  • .vscode/launch.json
  • Dockerfile
  • README.md
  • next.config.js
  • package.json
  • pnpm-workspace.yaml
  • scripts/docker-entrypoint.sh
  • scripts/env.sh
  • scripts/update-runtime-env.js
  • sonar-project.properties
  • src/domain/app/layout/pageLayout/PageLayout.tsx
  • src/domain/registration/__tests__/utils.test.ts
  • src/domain/registration/utils.ts
  • src/domain/signupGroup/participantAmountSelector/__tests__/ParticipantAmountSelector.test.tsx
  • src/domain/signupGroup/reservationTimer/__tests__/ReservationTimer.test.tsx
  • src/instrumentation-client.ts
  • src/pages/_document.tsx
  • src/pages/api/readiness.ts
  • src/setupTests.ts
  • src/types/runtime-env.d.ts
  • src/utils/__tests__/getEnvValue.test.ts
  • src/utils/__tests__/getPublicRuntimeConfig.test.ts
  • src/utils/__tests__/getServerRuntimeConfig.test.ts
  • src/utils/featureFlags.ts
  • src/utils/getEnvValue.ts
  • src/utils/getPublicRuntimeConfig.ts
  • src/utils/getServerRuntimeConfig.ts
  • src/utils/mockNextJsConfig.ts
  • vitest.config.ts
✅ Files skipped from review due to trivial changes (11)
  • .nvmrc
  • .gitignore
  • vitest.config.ts
  • src/setupTests.ts
  • .husky/commit-msg
  • src/domain/signupGroup/participantAmountSelector/tests/ParticipantAmountSelector.test.tsx
  • .vscode/launch.json
  • src/pages/api/readiness.ts
  • src/types/runtime-env.d.ts
  • sonar-project.properties
  • README.md
🚧 Files skipped from review as they are similar to previous changes (17)
  • scripts/docker-entrypoint.sh
  • src/domain/app/layout/pageLayout/PageLayout.tsx
  • src/utils/tests/getServerRuntimeConfig.test.ts
  • src/pages/_document.tsx
  • src/instrumentation-client.ts
  • src/utils/tests/getPublicRuntimeConfig.test.ts
  • src/domain/registration/utils.ts
  • scripts/env.sh
  • src/domain/signupGroup/reservationTimer/tests/ReservationTimer.test.tsx
  • pnpm-workspace.yaml
  • next.config.js
  • src/utils/getServerRuntimeConfig.ts
  • src/utils/getEnvValue.ts
  • src/domain/registration/tests/utils.test.ts
  • .dockerignore
  • src/utils/getPublicRuntimeConfig.ts
  • src/utils/mockNextJsConfig.ts

Comment thread package.json
Comment thread src/utils/__tests__/getEnvValue.test.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/utils/getEnvValue.ts`:
- Around line 20-37: The check for Node's process is unsafe in browsers; replace
the `if (process !== undefined)` guard in getEnvValue with a typeof check (`if
(typeof process !== 'undefined'`) and then safely read `process.env?.[key]` (or
ensure you only access `process.env` after the typeof guard) so that referencing
process.env in the `getEnvValue` function (the `processValue` lookup) cannot
throw a ReferenceError in browser runtimes; keep existing checks around
globalThis.window, warnedAboutMissingEnv, toEnvString, and runtimeEnvValue
intact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 99e5f135-0538-4c2c-bd33-efcc53b234c9

📥 Commits

Reviewing files that changed from the base of the PR and between 2f15820 and 42a1ef8.

📒 Files selected for processing (25)
  • .dockerignore
  • .env
  • .gitignore
  • Dockerfile
  • README.md
  • package.json
  • scripts/docker-entrypoint.sh
  • scripts/env.sh
  • scripts/update-runtime-env.js
  • sonar-project.properties
  • src/domain/app/layout/pageLayout/PageLayout.tsx
  • src/domain/registration/__tests__/utils.test.ts
  • src/domain/registration/utils.ts
  • src/instrumentation-client.ts
  • src/pages/_document.tsx
  • src/pages/api/readiness.ts
  • src/setupTests.ts
  • src/types/runtime-env.d.ts
  • src/utils/__tests__/getEnvValue.test.ts
  • src/utils/__tests__/getPublicRuntimeConfig.test.ts
  • src/utils/__tests__/getServerRuntimeConfig.test.ts
  • src/utils/featureFlags.ts
  • src/utils/getEnvValue.ts
  • src/utils/getPublicRuntimeConfig.ts
  • vitest.config.ts
✅ Files skipped from review due to trivial changes (5)
  • scripts/docker-entrypoint.sh
  • .gitignore
  • sonar-project.properties
  • src/domain/registration/tests/utils.test.ts
  • README.md
🚧 Files skipped from review as they are similar to previous changes (15)
  • vitest.config.ts
  • scripts/env.sh
  • src/types/runtime-env.d.ts
  • src/utils/tests/getServerRuntimeConfig.test.ts
  • src/setupTests.ts
  • src/domain/registration/utils.ts
  • src/utils/featureFlags.ts
  • .dockerignore
  • src/utils/tests/getPublicRuntimeConfig.test.ts
  • src/domain/app/layout/pageLayout/PageLayout.tsx
  • scripts/update-runtime-env.js
  • src/utils/getPublicRuntimeConfig.ts
  • package.json
  • src/instrumentation-client.ts
  • Dockerfile

Comment thread src/utils/getEnvValue.ts Outdated
@azure-pipelines

Copy link
Copy Markdown

e2e tests result is failed for https://linkedregistrations-pr297-ui.dev.hel.ninja 😿💢💥💥

@azure-pipelines

Copy link
Copy Markdown

LINKEDREGISTRATIONS-UI branch is deployed to platta: https://linkedregistrations-pr297-ui.dev.hel.ninja 🚀🚀🚀

- add runtime env generator script and shell wrappers for local/test
  and container startup
- generate public env config files and load env-config.js before
  app scripts
- add getEnvValue helper with runtime window._env_ fallback to
  process.env
- migrate Matomo, Sentry, feature flags, registration utils, and
  runtime config reads to getEnvValue
- update Dockerfile to include scripts, run env generation on startup,
  and use pnpm install flow
- run runtime env generation in dev/start/test scripts and document
  the workflow
- update ignore and coverage settings for generated/runtime scripts

Refs: LINK-2574
@jorilindell jorilindell force-pushed the LINK-2574-pnpm-migration branch from 42a1ef8 to 57b80bd Compare June 4, 2026 11:46
Comment on lines +28 to +31
if (separatorIndex < 0) {
return;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The parseEnvContent function does not unescape special characters like \n or \" in double-quoted .env values, leading to incorrect parsing of these variables.
Severity: LOW

Suggested Fix

Modify the parseEnvContent function to correctly handle and unescape standard escape sequences (e.g., \n, \t, \") for values enclosed in double quotes. This will align its behavior with standard .env file parsers and prevent silent data corruption if such variables are used in the future.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: scripts/update-runtime-env.js#L28-L31

Potential issue: The `parseEnvContent` function in `scripts/update-runtime-env.js` does
not correctly handle escaped characters within double-quoted values in `.env` files. For
example, a value like `"Hello\nWorld"` will be parsed as the literal string
`Hello\nWorld` instead of a string containing a newline character. While no current
environment variables use such escape sequences, this is a latent defect. If a developer
adds a variable with escaped quotes or newlines in the future, it would lead to silent
misconfiguration and unexpected behavior, as the application would receive a string with
literal backslashes instead of the intended characters.

@sonarqubecloud

sonarqubecloud Bot commented Jun 4, 2026

Copy link
Copy Markdown

@azure-pipelines

Copy link
Copy Markdown

e2e tests result is failed for https://linkedregistrations-pr297-ui.dev.hel.ninja 😿💢💥💥

@azure-pipelines

Copy link
Copy Markdown

LINKEDREGISTRATIONS-UI branch is deployed to platta: https://linkedregistrations-pr297-ui.dev.hel.ninja 🚀🚀🚀

@jorilindell jorilindell merged commit aada849 into main Jun 8, 2026
26 of 28 checks passed
@jorilindell jorilindell deleted the LINK-2574-pnpm-migration branch June 8, 2026 06:46
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