Skip to content

fix(os-service): use pathToFileURL for cross-platform log folder path#3030

Merged
MattPua merged 1 commit into
posthog-code/command-menu-developer-sectionfrom
posthog-code/fix-os-service-log-folder-path
Jun 30, 2026
Merged

fix(os-service): use pathToFileURL for cross-platform log folder path#3030
MattPua merged 1 commit into
posthog-code/command-menu-developer-sectionfrom
posthog-code/fix-os-service-log-folder-path

Conversation

@MattPua

@MattPua MattPua commented Jun 30, 2026

Copy link
Copy Markdown
Member

Summary

Follow-up to #3005. Fixes showLogFolder to produce a valid file URI on all platforms.

  • file://${path} breaks on Windows (C:\...file://C:\..., invalid)
  • pathToFileURL(path).href (Node built-in) handles this correctly on all platforms
  • Adds a test asserting the launcher is called with a file:// URL

Danger level: 1/5


Created with PostHog Code

@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 7efc24d.

@greptile-apps

greptile-apps Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix(os-service): use pathToFileURL for c..." | Re-trigger Greptile

Comment on lines +166 to +168
expect(urlLauncher.launch).toHaveBeenCalledWith(
expect.stringMatching(/^file:\/\//),
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 The assertion only checks the file:// protocol prefix, but the mock already sets logFolderPath: "/logs" — a deterministic value. On any platform pathToFileURL("/logs").href returns "file:///logs", so the test could assert the complete URL and thereby also verify that the correct path was forwarded to pathToFileURL. As written, the test would pass even if showLogFolder called pathToFileURL("") or any other path.

Suggested change
expect(urlLauncher.launch).toHaveBeenCalledWith(
expect.stringMatching(/^file:\/\//),
);
expect(urlLauncher.launch).toHaveBeenCalledWith("file:///logs");

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@MattPua MattPua force-pushed the posthog-code/command-menu-shortcuts branch from 844aef4 to cf81f7e Compare June 30, 2026 16:00
…, add test

Generated-By: PostHog Code
Task-Id: 422bdee4-0988-45ff-b47e-4337650d40b1
@MattPua MattPua force-pushed the posthog-code/fix-os-service-log-folder-path branch from aa88fce to 7efc24d Compare June 30, 2026 16:01
@MattPua MattPua changed the base branch from posthog-code/command-menu-shortcuts to posthog-code/command-menu-developer-section June 30, 2026 16:01
@MattPua

MattPua commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

Merged into #3031.

@MattPua MattPua merged commit 7efc24d into posthog-code/command-menu-developer-section Jun 30, 2026
23 of 26 checks passed
@MattPua MattPua deleted the posthog-code/fix-os-service-log-folder-path branch June 30, 2026 16:02
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.

1 participant