Add Kir-Pay integration#1045
Conversation
📝 WalkthroughWalkthroughAdds a KirPay backend component with leaderboard and balance access, a matching frontend leaderboard page and profile balance display, and a runtime config migration from Vite env vars to ChangesKirPay Component (Backend + Frontend)
Frontend Runtime Config Migration
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 OpenGrep (1.23.0)frontend/src/pages/profile/profile.page.tsx┌──────────────┐ �[32m✔�[39m �[1mOpengrep OSS�[0m [00.21][ERROR]: unable to find a config; path frontend/src/util/views/profile.view.ts┌──────────────┐ �[32m✔�[39m �[1mOpengrep OSS�[0m [00.17][ERROR]: unable to find a config; path frontend/src/util/paths.ts┌──────────────┐ �[32m✔�[39m �[1mOpengrep OSS�[0m [00.30][ERROR]: unable to find a config; path
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 11
🤖 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 `@backend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayService.kt`:
- Around line 61-63: The warning in KirPayService.fetchBalance currently logs
the raw email address on failure, which leaks PII. Update the catch block in
KirPayService so the log message no longer includes email; if correlation is
needed, use a non-PII internal identifier or a sanitized token instead. Keep the
existing failure handling behavior unchanged and adjust the log call around
log.warn accordingly.
- Around line 21-45: The cache in KirPayService currently treats an empty list
as both “not loaded” and “loaded but empty,” so getConsumptionLeaderboard keeps
refetching forever and can stampede the backend. Change cachedLeaderboard
handling in KirPayService to distinguish cache state from cached content, such
as by using a nullable/initialized flag or a separate loaded marker, and update
both refreshCache and getConsumptionLeaderboard to serve a legitimately empty
result without retrying on every call. Keep the existing scheduler flow, but
ensure only one cold-load path populates the cache before subsequent reads reuse
it.
- Around line 23-30: The KirPay client built in KirPayService’s kirPayClient is
currently used with blocking calls in the service methods, so a stalled upstream
can hang the caller indefinitely. Add an explicit timeout either on the
WebClient connector/read side when building kirPayClient or by applying timeout
handling to the Monos in the KirPayService methods that call block(), and make
sure the existing request paths in the service use the timed client or timed
reactive pipeline consistently.
In
`@backend/src/main/kotlin/hu/bme/sch/cmsch/component/profile/ProfileComponent.kt`:
- Around line 148-152: The new profile-level showKirPayBalance setting in
ProfileComponent is duplicating an existing Kir-Pay feature toggle, so the
balance visibility is now controlled by two independent switches. Remove the
extra gate in ProfileService and rely on the existing
kirPayComponent.showKirPayBalance path used by KirPayService, or otherwise wire
both places to the same underlying setting so there is a single source of truth
for balance visibility. Refer to ProfileComponent, ProfileService, and
KirPayService when making the change.
In `@frontend/entrypoint.sh`:
- Around line 6-8: The placeholder substitution loop in entrypoint.sh uses a
bash-only indirect expansion and can break under /bin/sh, so update the VITE_
variable iteration and replacement logic to be POSIX-sh compatible. In the
section that builds placeholder and runs sed, fetch each variable’s value
without bashism and escape any special replacement characters such as &, \, and
| before substitution so HTML replacement works reliably for all env values.
In `@frontend/index.html`:
- Line 34: The inline error reporter is using the raw window.config.API_BASE_URL
instead of the same localhost fallback used by environment.config.ts, so missing
runtime tokens can break reporting only. Update the inline fetch setup in
index.html to resolve the API base through the same fallback logic as the app
(with the localhost:8080 default) and ensure any error-reporting request path
uses that resolved base consistently.
In `@frontend/src/api/hooks/kirpay/useKirPayLeaderboardQuery.ts`:
- Around line 1-5: The import order in useKirPayLeaderboardQuery is causing the
lint failure; move joinPath so it is grouped with the other internal imports
before the third-party imports like useQuery and axios. Keep the existing
imports otherwise unchanged, and ensure the file follows the project’s import
sorting convention.
In `@frontend/src/App.tsx`:
- Line 28: The new KirPayLeaderboardPage import in App should be moved into the
existing sorted group of page imports so the linter order matches CI
expectations. Update the import block in App.tsx around KirPayLeaderboardPage
and the surrounding page imports to keep the list alphabetically/consistently
ordered with the project’s import sorting rules.
In `@frontend/src/global.d.ts`:
- Around line 18-23: The Window augmentation in global.d.ts is currently inside
a top-level declare global block in a non-module declaration file, which
TypeScript rejects. Make the file an external module by adding an empty export,
or move the Window interface augmentation to top level, so the declarations
merge correctly while keeping the WindowConfig and processAndReportError symbols
intact.
In `@frontend/src/pages/kirpay-leaderboard/kirpay-leaderboard.page.tsx`:
- Around line 34-39: The row key in the kirpay leaderboard table is unstable
because TableRow uses entry.name, which is display text and may collide across
entries. Update the mapping in kirpay-leaderboard.page.tsx to use a stable
unique identifier from each entry if one is available from the backend; if not,
adjust the data shape or rendering logic so TableRow keys are derived from a
guaranteed-unique field instead of name.
- Around line 9-12: The KirPay leaderboard fetch is happening even when KirPay
is unavailable because `useKirPayLeaderboardQuery()` is called before the
`!component` guard in `KirPayLeaderboardPage`. Move the query invocation so it
only runs after confirming `component` exists, or otherwise conditionally
disable the query based on the config check, and keep `ComponentUnavailable` as
the early return for the unavailable case.
🪄 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: efa99f1a-3304-4bd9-8286-4400beb0c9f0
📒 Files selected for processing (37)
backend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayApiController.ktbackend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayComponent.ktbackend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayLeaderboardView.ktbackend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayService.ktbackend/src/main/kotlin/hu/bme/sch/cmsch/component/profile/ProfileComponent.ktbackend/src/main/kotlin/hu/bme/sch/cmsch/component/profile/ProfileService.ktbackend/src/main/kotlin/hu/bme/sch/cmsch/component/profile/ProfileView.ktbackend/src/main/resources/config/application-env.propertiesbackend/src/main/resources/config/application.propertiesfrontend/.env.dockerfrontend/.env.examplefrontend/Dockerfilefrontend/entrypoint.shfrontend/index.htmlfrontend/package.jsonfrontend/planfrontend/src/App.tsxfrontend/src/api/contexts/config/types.tsfrontend/src/api/hooks/kirpay/useKirPayLeaderboardQuery.tsfrontend/src/api/hooks/queryKeys.tsfrontend/src/api/hooks/riddle/useRiddleDeatilsQuery.tsfrontend/src/api/hooks/riddle/useRiddleHintQuery.tsfrontend/src/api/hooks/riddle/useRiddleHistoryQuery.tsfrontend/src/api/hooks/riddle/useRiddleListQuery.tsfrontend/src/api/hooks/riddle/useRiddleSkipMutation.tsfrontend/src/api/hooks/riddle/useRiddleSubmitMutation.tsfrontend/src/global.d.tsfrontend/src/pages/kirpay-leaderboard/kirpay-leaderboard.page.tsxfrontend/src/pages/profile/profile.page.tsxfrontend/src/util/configs/environment.config.tsfrontend/src/util/paths.tsfrontend/src/util/views/kirPayLeaderboard.view.tsfrontend/src/util/views/profile.view.tsfrontend/src/vite-env.d.tsfrontend/tsconfig.app.jsonhelm/cmsch/templates/cmsch-config.ymlhelm/cmsch/values.yaml
💤 Files with no reviewable changes (3)
- frontend/tsconfig.app.json
- frontend/src/vite-env.d.ts
- frontend/.env.example
| val kirPayGroup by SettingGroup(fieldName = "Kir-Pay", | ||
| description = "A Kir-Pay komponensnek is be kell kapcsolva lennie, hogy az itteni beállítások működjenek") | ||
|
|
||
| var showKirPayBalance by BooleanSettingRef(true, | ||
| fieldName = "Kir-Pay egyenleg látható", description = "Megjelenjen-e a Kir-Pay egyenleg a profilban") |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
This creates a second independent showKirPayBalance switch.
ProfileService now gates the field on profileComponent.showKirPayBalance, but backend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayService.kt, Lines 47-49 already gate the upstream call on kirPayComponent.showKirPayBalance. Turning on this new profile flag alone still returns no balance, so the feature now has two separate toggles for one behavior.
🤖 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
`@backend/src/main/kotlin/hu/bme/sch/cmsch/component/profile/ProfileComponent.kt`
around lines 148 - 152, The new profile-level showKirPayBalance setting in
ProfileComponent is duplicating an existing Kir-Pay feature toggle, so the
balance visibility is now controlled by two independent switches. Remove the
extra gate in ProfileService and rely on the existing
kirPayComponent.showKirPayBalance path used by KirPayService, or otherwise wire
both places to the same underlying setting so there is a single source of truth
for balance visibility. Refer to ProfileComponent, ProfileService, and
KirPayService when making the change.
| for var in $(env | grep '^VITE_' | cut -d= -f1); do | ||
| placeholder="__${var}__" | ||
| sed -i "s|${placeholder}|${!var}|g" "$HTML" |
There was a problem hiding this comment.
🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/sh
cat -n frontend/entrypoint.sh | sed -n '1,120p'Repository: kir-dev/cmsch
Length of output: 444
Fix the placeholder substitution in frontend/entrypoint.sh:6-8
${!var} is a bashism, so this entrypoint fails under /bin/sh before nginx starts. The sed replacement also needs escaping for values containing &, \, or |.
🧰 Tools
🪛 Shellcheck (0.11.0)
[warning] 8-8: In POSIX sh, indirect expansion is undefined.
(SC3053)
🤖 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 `@frontend/entrypoint.sh` around lines 6 - 8, The placeholder substitution loop
in entrypoint.sh uses a bash-only indirect expansion and can break under
/bin/sh, so update the VITE_ variable iteration and replacement logic to be
POSIX-sh compatible. In the section that builds placeholder and runs sed, fetch
each variable’s value without bashism and escape any special replacement
characters such as &, \, and | before substitution so HTML replacement works
reliably for all env values.
Source: Linters/SAST tools
| {data.entries.map((entry, index) => ( | ||
| <TableRow key={entry.name}> | ||
| <TableCell className="font-medium">{index + 1}</TableCell> | ||
| <TableCell>{entry.name}</TableCell> | ||
| <TableCell className="text-right">{entry.itemCount} db</TableCell> | ||
| </TableRow> |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the component
sed -n '1,220p' frontend/src/pages/kirpay-leaderboard/kirpay-leaderboard.page.tsx
printf '\n--- SEARCH: kirpay leaderboard types/usages ---\n'
rg -n "kirpay|leaderboard|itemCount|entries" frontend/src -g '!**/node_modules/**'
printf '\n--- SEARCH: backend payload shape / API contract ---\n'
rg -n "itemCount|name" . -g '!**/node_modules/**' -g '!**/dist/**' -g '!**/build/**'Repository: kir-dev/cmsch
Length of output: 50371
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- frontend/src/util/views/kirPayLeaderboard.view.ts ---'
sed -n '1,120p' frontend/src/util/views/kirPayLeaderboard.view.ts
printf '\n%s\n' '--- frontend/src/api/hooks/kirpay/useKirPayLeaderboardQuery.ts ---'
sed -n '1,120p' frontend/src/api/hooks/kirpay/useKirPayLeaderboardQuery.ts
printf '\n%s\n' '--- backend / api kirpay-leaderboard references ---'
rg -n "kirpay-leaderboard|KirPayLeaderboard|kirPayLeaderboard|itemCount" . \
-g '!**/node_modules/**' -g '!**/dist/**' -g '!**/build/**' -g '!**/.git/**' \
| head -n 80Repository: kir-dev/cmsch
Length of output: 5064
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- backend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayLeaderboardView.kt ---'
sed -n '1,120p' backend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayLeaderboardView.kt
printf '\n%s\n' '--- backend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayApiController.kt ---'
sed -n '1,160p' backend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayApiController.kt
printf '\n%s\n' '--- backend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayService.kt ---'
sed -n '1,180p' backend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayService.ktRepository: kir-dev/cmsch
Length of output: 5607
Use a stable row key here. entry.name is display text, not a unique identifier; this payload has no stable ID, so duplicate names can collide and make React reuse the wrong row. If the backend can expose an ID, use that instead.
🤖 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 `@frontend/src/pages/kirpay-leaderboard/kirpay-leaderboard.page.tsx` around
lines 34 - 39, The row key in the kirpay leaderboard table is unstable because
TableRow uses entry.name, which is display text and may collide across entries.
Update the mapping in kirpay-leaderboard.page.tsx to use a stable unique
identifier from each entry if one is available from the backend; if not, adjust
the data shape or rendering logic so TableRow keys are derived from a
guaranteed-unique field instead of name.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
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 `@backend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayService.kt`:
- Around line 33-36: The refreshCache() flow in KirPayService is overwriting
cachedLeaderboard even when fetchConsumptionLeaderboard() fails and returns an
empty fallback, which can evict the last known good snapshot. Change
fetchConsumptionLeaderboard() to return a distinct success/failure result
instead of collapsing errors into emptyList(), and update refreshCache() to
assign cachedLeaderboard only when the fetch succeeds. Keep the existing
cachedLeaderboard value unchanged on failures, and preserve the current logging
in refreshCache() for successful refreshes.
In `@frontend/src/api/hooks/kirpay/useKirPayLeaderboardQuery.ts`:
- Around line 7-14: The KirPay leaderboard query hook always runs, which causes
a failing request when KirPay is disabled; update useKirPayLeaderboardQuery to
accept an enabled flag and pass it through to useQuery, then update
KirPayLeaderboardPage to call it with !!component so the request is skipped when
the component gate is off.
🪄 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: 1140593b-a048-4fef-803a-d125ad63e7cb
📒 Files selected for processing (36)
backend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayApiController.ktbackend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayComponent.ktbackend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayLeaderboardView.ktbackend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayService.ktbackend/src/main/kotlin/hu/bme/sch/cmsch/component/profile/ProfileComponent.ktbackend/src/main/kotlin/hu/bme/sch/cmsch/component/profile/ProfileService.ktbackend/src/main/kotlin/hu/bme/sch/cmsch/component/profile/ProfileView.ktbackend/src/main/resources/config/application-env.propertiesbackend/src/main/resources/config/application.propertiesfrontend/.env.dockerfrontend/.env.examplefrontend/Dockerfilefrontend/entrypoint.shfrontend/index.htmlfrontend/package.jsonfrontend/src/App.tsxfrontend/src/api/contexts/config/types.tsfrontend/src/api/hooks/kirpay/useKirPayLeaderboardQuery.tsfrontend/src/api/hooks/queryKeys.tsfrontend/src/api/hooks/riddle/useRiddleDeatilsQuery.tsfrontend/src/api/hooks/riddle/useRiddleHintQuery.tsfrontend/src/api/hooks/riddle/useRiddleHistoryQuery.tsfrontend/src/api/hooks/riddle/useRiddleListQuery.tsfrontend/src/api/hooks/riddle/useRiddleSkipMutation.tsfrontend/src/api/hooks/riddle/useRiddleSubmitMutation.tsfrontend/src/global.d.tsfrontend/src/pages/kirpay-leaderboard/kirpay-leaderboard.page.tsxfrontend/src/pages/profile/profile.page.tsxfrontend/src/util/configs/environment.config.tsfrontend/src/util/paths.tsfrontend/src/util/views/kirPayLeaderboard.view.tsfrontend/src/util/views/profile.view.tsfrontend/src/vite-env.d.tsfrontend/tsconfig.app.jsonhelm/cmsch/templates/cmsch-config.ymlhelm/cmsch/values.yaml
💤 Files with no reviewable changes (3)
- frontend/.env.example
- frontend/tsconfig.app.json
- frontend/src/vite-env.d.ts
✅ Files skipped from review due to trivial changes (5)
- helm/cmsch/values.yaml
- frontend/src/util/views/profile.view.ts
- frontend/src/util/views/kirPayLeaderboard.view.ts
- frontend/package.json
- helm/cmsch/templates/cmsch-config.yml
🚧 Files skipped from review as they are similar to previous changes (23)
- frontend/src/pages/profile/profile.page.tsx
- backend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayLeaderboardView.kt
- backend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayApiController.kt
- frontend/src/api/hooks/riddle/useRiddleHintQuery.ts
- backend/src/main/kotlin/hu/bme/sch/cmsch/component/profile/ProfileView.kt
- frontend/src/global.d.ts
- frontend/index.html
- frontend/src/api/hooks/queryKeys.ts
- frontend/src/api/hooks/riddle/useRiddleHistoryQuery.ts
- frontend/src/util/paths.ts
- backend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayComponent.kt
- frontend/src/api/hooks/riddle/useRiddleListQuery.ts
- backend/src/main/resources/config/application.properties
- frontend/src/api/hooks/riddle/useRiddleDeatilsQuery.ts
- backend/src/main/resources/config/application-env.properties
- frontend/src/api/hooks/riddle/useRiddleSubmitMutation.ts
- frontend/Dockerfile
- backend/src/main/kotlin/hu/bme/sch/cmsch/component/profile/ProfileComponent.kt
- backend/src/main/kotlin/hu/bme/sch/cmsch/component/profile/ProfileService.kt
- frontend/src/api/contexts/config/types.ts
- frontend/src/api/hooks/riddle/useRiddleSkipMutation.ts
- frontend/src/pages/kirpay-leaderboard/kirpay-leaderboard.page.tsx
- frontend/src/util/configs/environment.config.ts
| fun refreshCache() { | ||
| if (!kirPayComponent.leaderboardEnabled) return | ||
| cachedLeaderboard = fetchConsumptionLeaderboard() | ||
| log.info("Kir-Pay consumption leaderboard cache refreshed, {} entries", cachedLeaderboard.size) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Don't evict the last good leaderboard snapshot on refresh failures.
fetchConsumptionLeaderboard() turns every upstream error into emptyList(), so one failed scheduled refresh replaces a valid cache with “no data” until the next successful run. Return a distinct failure state here and only overwrite cachedLeaderboard when the fetch actually succeeds.
Proposed fix
fun refreshCache() {
if (!kirPayComponent.leaderboardEnabled) return
- cachedLeaderboard = fetchConsumptionLeaderboard()
- log.info("Kir-Pay consumption leaderboard cache refreshed, {} entries", cachedLeaderboard.size)
+ val refreshed = fetchConsumptionLeaderboard() ?: return
+ cachedLeaderboard = refreshed
+ log.info("Kir-Pay consumption leaderboard cache refreshed, {} entries", refreshed.size)
}
@@
- private fun fetchConsumptionLeaderboard(): List<KirPayLeaderboardEntry> {
+ private fun fetchConsumptionLeaderboard(): List<KirPayLeaderboardEntry>? {
return try {
val response = kirPayClient.get()
.uri("/consumption-leaderboard")
.retrieve()
.bodyToMono<List<Map<String, Any>>>()
@@
response.map {
KirPayLeaderboardEntry(
name = it["name"] as? String ?: "n/a",
itemCount = (it["itemCount"] as? Number)?.toLong() ?: 0
)
}
} catch (e: Exception) {
log.warn("Failed to fetch Kir-Pay consumption leaderboard: {}", e.message)
- listOf()
+ null
}
}Also applies to: 67-84
🤖 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 `@backend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayService.kt`
around lines 33 - 36, The refreshCache() flow in KirPayService is overwriting
cachedLeaderboard even when fetchConsumptionLeaderboard() fails and returns an
empty fallback, which can evict the last known good snapshot. Change
fetchConsumptionLeaderboard() to return a distinct success/failure result
instead of collapsing errors into emptyList(), and update refreshCache() to
assign cachedLeaderboard only when the fetch succeeds. Keep the existing
cachedLeaderboard value unchanged on failures, and preserve the current logging
in refreshCache() for successful refreshes.
There was a problem hiding this comment.
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 `@frontend/Dockerfile`:
- Around line 27-34: The frontend startup path in entrypoint.sh only substitutes
VITE_* placeholders when matching env vars exist, so missing values remain
unresolved and break the fallback handling in environment.config.ts. Update the
entrypoint logic referenced by the Dockerfile ENTRYPOINT to also clear or
default any absent __VITE_*__ tokens before Nginx serves index.html, ensuring
placeholders like PASS_SERVER_URL become undefined and
APP_CONFIG_CACHE_TTL_SECONDS does not parse as NaN when unset.
🪄 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: ad193f87-d516-40c2-a1bb-093589d02512
📒 Files selected for processing (36)
backend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayApiController.ktbackend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayComponent.ktbackend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayLeaderboardView.ktbackend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayService.ktbackend/src/main/kotlin/hu/bme/sch/cmsch/component/profile/ProfileComponent.ktbackend/src/main/kotlin/hu/bme/sch/cmsch/component/profile/ProfileService.ktbackend/src/main/kotlin/hu/bme/sch/cmsch/component/profile/ProfileView.ktbackend/src/main/resources/config/application-env.propertiesbackend/src/main/resources/config/application.propertiesfrontend/.env.dockerfrontend/.env.examplefrontend/Dockerfilefrontend/entrypoint.shfrontend/index.htmlfrontend/package.jsonfrontend/src/App.tsxfrontend/src/api/contexts/config/types.tsfrontend/src/api/hooks/kirpay/useKirPayLeaderboardQuery.tsfrontend/src/api/hooks/queryKeys.tsfrontend/src/api/hooks/riddle/useRiddleDeatilsQuery.tsfrontend/src/api/hooks/riddle/useRiddleHintQuery.tsfrontend/src/api/hooks/riddle/useRiddleHistoryQuery.tsfrontend/src/api/hooks/riddle/useRiddleListQuery.tsfrontend/src/api/hooks/riddle/useRiddleSkipMutation.tsfrontend/src/api/hooks/riddle/useRiddleSubmitMutation.tsfrontend/src/global.d.tsfrontend/src/pages/kirpay-leaderboard/kirpay-leaderboard.page.tsxfrontend/src/pages/profile/profile.page.tsxfrontend/src/util/configs/environment.config.tsfrontend/src/util/paths.tsfrontend/src/util/views/kirPayLeaderboard.view.tsfrontend/src/util/views/profile.view.tsfrontend/src/vite-env.d.tsfrontend/tsconfig.app.jsonhelm/cmsch/templates/cmsch-config.ymlhelm/cmsch/values.yaml
💤 Files with no reviewable changes (3)
- frontend/tsconfig.app.json
- frontend/.env.example
- frontend/src/vite-env.d.ts
✅ Files skipped from review due to trivial changes (3)
- backend/src/main/resources/config/application-env.properties
- frontend/src/util/views/kirPayLeaderboard.view.ts
- frontend/package.json
🚧 Files skipped from review as they are similar to previous changes (23)
- helm/cmsch/templates/cmsch-config.yml
- frontend/src/App.tsx
- backend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayLeaderboardView.kt
- backend/src/main/kotlin/hu/bme/sch/cmsch/component/kirpay/KirPayApiController.kt
- frontend/src/api/hooks/queryKeys.ts
- frontend/src/pages/profile/profile.page.tsx
- backend/src/main/kotlin/hu/bme/sch/cmsch/component/profile/ProfileComponent.kt
- frontend/index.html
- frontend/src/api/hooks/riddle/useRiddleDeatilsQuery.ts
- frontend/entrypoint.sh
- frontend/src/pages/kirpay-leaderboard/kirpay-leaderboard.page.tsx
- frontend/src/api/hooks/riddle/useRiddleSkipMutation.ts
- frontend/src/api/hooks/kirpay/useKirPayLeaderboardQuery.ts
- frontend/src/util/paths.ts
- helm/cmsch/values.yaml
- backend/src/main/resources/config/application.properties
- frontend/src/global.d.ts
- frontend/src/api/hooks/riddle/useRiddleHintQuery.ts
- frontend/src/api/hooks/riddle/useRiddleHistoryQuery.ts
- frontend/src/api/hooks/riddle/useRiddleSubmitMutation.ts
- frontend/src/api/hooks/riddle/useRiddleListQuery.ts
- frontend/src/util/configs/environment.config.ts
- backend/src/main/kotlin/hu/bme/sch/cmsch/component/profile/ProfileService.kt
| COPY entrypoint.sh /entrypoint.sh | ||
| RUN chmod +x /entrypoint.sh | ||
|
|
||
| # Expose the desired port (default is 80 for Nginx) | ||
| EXPOSE 80 | ||
|
|
||
| # Set the command to start the Nginx server | ||
| CMD ["nginx", "-g", "daemon off;"] | ||
| # Set the entrypoint to inject runtime env vars then start Nginx | ||
| ENTRYPOINT ["/entrypoint.sh"] |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Handle unset VITE_* vars before serving index.html.
Wiring /entrypoint.sh as the startup path makes the image serve unresolved __VITE_*__ tokens whenever a runtime variable is omitted, because the script only replaces variables that are present in env. That breaks the new frontend fallback logic: for example, PASS_SERVER_URL stays a truthy placeholder instead of becoming undefined, and APP_CONFIG_CACHE_TTL_SECONDS parses to NaN in frontend/src/util/configs/environment.config.ts:1-13. The entrypoint should also clear or default missing placeholders, not just substitute the vars that exist.
🤖 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 `@frontend/Dockerfile` around lines 27 - 34, The frontend startup path in
entrypoint.sh only substitutes VITE_* placeholders when matching env vars exist,
so missing values remain unresolved and break the fallback handling in
environment.config.ts. Update the entrypoint logic referenced by the Dockerfile
ENTRYPOINT to also clear or default any absent __VITE_*__ tokens before Nginx
serves index.html, ensuring placeholders like PASS_SERVER_URL become undefined
and APP_CONFIG_CACHE_TTL_SECONDS does not parse as NaN when unset.
Summary by CodeRabbit
window.config) for easier deployment updates.