Skip to content

fix: open logs with a % in the path, or opened from a remote window - #1283

Merged
lcottercertinia merged 6 commits into
certinia:mainfrom
lukecotter:bug-752-log-path-percent
Nov 13, 2026
Merged

lcottercertinia merged 6 commits into
certinia:mainfrom
lukecotter:bug-752-log-path-percent

Conversation

@lukecotter

@lukecotter lukecotter commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

📝 PR Overview

Two separate causes gave "Could not read log" in #752. This branch fixes both.

A % in the path. A log in a folder whose name holds a literal %xx, such as Enterprise%20Salesforce, would not open. The viewer showed "Error reading log file: 401". The extension sent the webview the log URI with its % left unencoded. The webview then read %20 as a space and asked for a path outside the panel's resource roots.

A local log opened from a remote window. In a WSL, SSH or dev container window, a log stored on the client machine has a vscode-local: URI. asWebviewUri puts that scheme into the URL as it is, but VS Code translates the panel's resource roots to file: on the client side. The schemes do not match, so the request is refused. The reporter saw a 401 on WSL. A dev container on macOS gives a 404.

🛠️ Changes made

  • Encode the log URI sent to the webview (toString(), not toString(true)).
  • Encode the viewer's script and stylesheet URIs the same way. They had the same defect, so an install path with a literal %xx would leave the panel blank.
  • Make the test's asWebviewUri stub keep the URI's encoding. The old stub rebuilt the URI from its decoded path, which hid this bug.
  • For a vscode-local log, read the file in the extension host and send it in the existing logData field of the fetchLog message. The webview already prefers logData to the fetch. Every other scheme still goes through the fetch.
  • Send that log as a Uint8Array, not a string. This is the one change to the message contract: logData is now string | Uint8Array. VS Code transfers a plain Uint8Array as binary, and the parser reads it directly. The file read returns a Node Buffer, which VS Code would post as a JSON array of numbers, so the host wraps it in a plain Uint8Array view first.
  • In the webview, use the message body whenever the message has one. An empty body was read as "no body", so an empty local log still went to the fetch that fails.

🧩 Type of change (check all applicable)

  • 🐛 Bug fix - something not working as expected
  • ✨ New feature – adds new functionality
  • ♻️ Refactor - internal changes with no user impact
  • ⚡ Performance Improvement
  • 📝 Documentation - README or documentation site changes
  • 🔧 Chore - dev tooling, CI, config
  • 💥 Breaking change

📷 Screenshots / gifs / video [optional]

N/A

🔗 Related Issues

fixes #752

✅ Tests added?

  • 👍 yes
  • 🙅 no, not needed
  • 🙋 no, I need help

Test plan:

  • pnpm exec jest --selectProjects lana log-viewer: 3345 passed.
  • pnpm lint: clean.
  • pnpm test:e2e:web: 2 passed.
  • Manual, percent: put a log in a folder named Enterprise%20Salesforce, open it, then run Log: Show Apex Log Analysis. On 1.24.0 it fails with the 401. On this branch the timeline renders.
  • Manual, remote window: VS Code Insiders 1.147 on macOS with a Debian dev container, and the extension installed in the container. Open a log on the Mac with File > Open File… > Show Local, then run Log: Show Apex Log Analysis. The Marketplace pre-release fails with a 404 on a vscode-local+… URL. A VSIX built from this branch opens the log, and a log that holds only the log level line shows the empty states.

📚 Docs updated?

  • 🔖 README.md
  • 🔖 CHANGELOG.md
  • 📖 help site
  • 🧪 Marked any pre-release-only features (README 🧪 badge — see RELEASING.md)
  • 🙅 not needed

Anything else we need to know? [optional]

  • There are no memory or time measurements for the bytes path against the string path.
  • The remote window case was reproduced in a dev container, not in WSL. The failed URL has the same vscode-local+ host as the reporter's.

The webview got the log URI with its percent signs left unencoded, so a
folder named Enterprise%20Salesforce was read as "Enterprise Salesforce".
That path is outside the panel's resource roots, so the fetch failed with
"Error reading log file: 401".

The viewer's script and stylesheet URIs had the same defect, so an
install path with a literal %xx would leave the panel blank. They are
encoded too.

Fixes certinia#752
In a WSL, SSH or container window, a log on the client machine has a
`vscode-local` URI. The webview cannot fetch that scheme, so the
extension reads the log and sends the text in the message.
@lukecotter lukecotter changed the title fix: stop the 401 when a log's path contains a percent sign fix: open logs with a % in the path, or opened from a remote window Nov 13, 2026
An empty body was read as "no body", so the webview fetched the URI it cannot read. The webview now uses the body whenever the message has one.
The remote window fix had no test for an empty log, a failed read, or a body the caller supplied. The percent fix had no test for the script and stylesheet URIs.
The entry named only file paths and the 401. A user who opens a local log from a remote window would not recognise it.
@lukecotter
lukecotter marked this pull request as ready for review November 13, 2026 12:33
The log was decoded to a string in the extension host and copied to the
webview. It now goes as a Uint8Array, which VS Code transfers as binary
and the parser reads directly.
@lcottercertinia
lcottercertinia merged commit c80cc02 into certinia:main Nov 13, 2026
9 checks passed
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.

Error Could not read log when opening log file

2 participants