fix: prevent white screen when log_creds.txt is missing fields#17
Conversation
When log_creds.txt was empty or shorter than 4 non-empty lines, the
destructure left apiKey/apiSecret/errorLogUrl/telemetryUrl as
undefined. The original code then wrapped them in encodeURI(...),
which turned telemetryUrl into the literal string "undefined".
Because "undefined" is truthy, the hasCreds guard in
TelemetryManager did not skip telemetry, and at first render
navigator.sendBeacon("undefined", ...) was called. Chromium throws
synchronously since the URL is not HTTP/S; the unhandled rejection
during boot aborted Vue mount and the window stayed blank.
Return the empty Creds object when any required field is missing so
the downstream hasCreds checks correctly skip both telemetry and
error-log reporting.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughThe PR fixes macOS build failures by switching from a custom ChangesmacOS Build Failure Fixes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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.
🧹 Nitpick comments (3)
main/contactMothership.ts (1)
53-64: 💤 Low valueConsider guarding against empty
errorLogUrlbefore callingfetch.When credentials are missing,
errorLogUrlwill be an empty string.fetch('')attempts a relative request that will fail. While the error is caught, adding an early return would avoid the unnecessary network call.♻️ Proposed fix
export async function sendError(body: string, main: Main) { const { errorLogUrl, tokenString } = getUrlAndTokenString(); + if (!errorLogUrl) { + return; + } const headers = { Authorization: tokenString,🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@main/contactMothership.ts` around lines 53 - 64, The sendError function calls fetch even when getUrlAndTokenString() returns an empty errorLogUrl, causing a pointless relative request; update sendError to check the errorLogUrl returned by getUrlAndTokenString() and return early (optionally log via rendererLog(main, ...) if you want visibility) when errorLogUrl is falsy/empty so fetch is only invoked with a valid URL; keep the existing catch to handle real network errors.MACOS_BUILD_FIX.md (1)
36-40: 💤 Low valueMinor: Add language specifier to fenced code blocks.
The static analysis tool flagged these blocks at lines 36 and 65 as missing language specifiers. Using
textorconsolefor error output would satisfy the linter.📝 Proposed fix
-``` +```text TypeError: Failed to execute 'sendBeacon' on 'Navigator': Beacons are only supported over HTTP(S).Similarly for line 65: ```diff -``` +```text $ codesign -dv --verbose=4 "RUKN Books.app"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@MACOS_BUILD_FIX.md` around lines 36 - 40, The fenced code blocks showing the runtime error "TypeError: Failed to execute 'sendBeacon' on 'Navigator': Beacons are only supported over HTTP(S)." and the shell line beginning with "$ codesign -dv --verbose=4 \"RUKN Books.app\"" are missing language specifiers; update those fenced blocks to include a language token such as "text" or "console" (e.g., change ``` to ```text or ```console) so the linter/static analysis no longer flags them and the output is rendered correctly.main.ts (1)
155-165: 💤 Low valueConsider adding path traversal protection.
The
decodeURI(url.pathname)could theoretically contain../sequences. While practical exploitation is limited since only the renderer can makeapp://requests andcontextIsolationis enabled, adding a guard would be a defense-in-depth measure.🛡️ Proposed fix
registerAppProtocol() { if (!this.appProtocolRegistered) { protocol.registerFileProtocol('app', (request, callback) => { const url = new URL(request.url); - const filePath = path.join(__dirname, 'src', decodeURI(url.pathname)); + const srcDir = path.join(__dirname, 'src'); + const filePath = path.join(srcDir, decodeURI(url.pathname)); + // Ensure the resolved path is within srcDir + if (!filePath.startsWith(srcDir + path.sep) && filePath !== srcDir) { + callback({ error: -6 }); // NET::ERR_FILE_NOT_FOUND + return; + } callback({ path: filePath }); }); this.appProtocolRegistered = true; } this.winURL = 'app://./index.html'; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@main.ts` around lines 155 - 165, The registerAppProtocol handler currently uses decodeURI(url.pathname) directly which allows path traversal like "../"; in registerAppProtocol (inside the protocol.registerFileProtocol callback) sanitize the requested path by resolving it against the app content root (e.g., path.resolve(__dirname, 'src', decodeURI(url.pathname))) then verify the resolved path startsWith the allowed root (path.resolve(__dirname, 'src')); if the check fails, return an error or a safe fallback (e.g., serve index.html or callback with an error), otherwise callback with the resolved path; update the variables referenced (decodeURI(url.pathname), filePath, callback) accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@MACOS_BUILD_FIX.md`:
- Around line 36-40: The fenced code blocks showing the runtime error
"TypeError: Failed to execute 'sendBeacon' on 'Navigator': Beacons are only
supported over HTTP(S)." and the shell line beginning with "$ codesign -dv
--verbose=4 \"RUKN Books.app\"" are missing language specifiers; update those
fenced blocks to include a language token such as "text" or "console" (e.g.,
change ``` to ```text or ```console) so the linter/static analysis no longer
flags them and the output is rendered correctly.
In `@main.ts`:
- Around line 155-165: The registerAppProtocol handler currently uses
decodeURI(url.pathname) directly which allows path traversal like "../"; in
registerAppProtocol (inside the protocol.registerFileProtocol callback) sanitize
the requested path by resolving it against the app content root (e.g.,
path.resolve(__dirname, 'src', decodeURI(url.pathname))) then verify the
resolved path startsWith the allowed root (path.resolve(__dirname, 'src')); if
the check fails, return an error or a safe fallback (e.g., serve index.html or
callback with an error), otherwise callback with the resolved path; update the
variables referenced (decodeURI(url.pathname), filePath, callback) accordingly.
In `@main/contactMothership.ts`:
- Around line 53-64: The sendError function calls fetch even when
getUrlAndTokenString() returns an empty errorLogUrl, causing a pointless
relative request; update sendError to check the errorLogUrl returned by
getUrlAndTokenString() and return early (optionally log via rendererLog(main,
...) if you want visibility) when errorLogUrl is falsy/empty so fetch is only
invoked with a valid URL; keep the existing catch to handle real network errors.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d80dcead-1470-41b4-8d0e-5527ebde18a9
📒 Files selected for processing (5)
MACOS_BUILD_FIX.mdbuild/scripts/build.mjsmain.tsmain/contactMothership.tspackage.json
50bfbbe to
ba3b22b
Compare
https://tasko.rukn.sh/tasko/task/TASK-2026-00479
Summary by CodeRabbit
Release Notes v0.48.0
Bug Fixes
Chores