Skip to content

fix: stop the 401 when a log's path contains a percent sign - #1283

Draft
lukecotter wants to merge 1 commit into
certinia:mainfrom
lukecotter:bug-752-log-path-percent
Draft

lukecotter wants to merge 1 commit into
certinia:mainfrom
lukecotter:bug-752-log-path-percent

Conversation

@lukecotter

Copy link
Copy Markdown
Collaborator

📝 PR Overview

A log in a folder whose name holds a literal %xx, such as Enterprise%20Salesforce, would not open. The viewer showed "Could not read log: 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.

This branch sends every webview URI fully encoded. In VS Code Web, the same log failed before this change and opens after it. A folder with a real space opens on both builds, which is why earlier repro attempts with spaces passed.

🛠️ Changes made

  • Encode the log URI sent to the webview (toString(), not toString(true)). This is the Error Could not read log when opening log file #752 fix.
  • 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.
  • Add a test that a path holding a literal %20 reaches the webview unchanged. It fails on the old code.

🧩 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: 402 passed.
  • pnpm test:e2e:web: 2 passed.
  • Manual: 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.

📚 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]

A later comment on #752 reports the same 401 when a WSL window opens a log stored on Windows. That case is not confirmed to have this cause yet. It needs the reporter's file path.

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

This branch has not been deployed

No deployments
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

1 participant