fix: send rootResourcePath instead of rootDoc_id in compile request#356
Conversation
|
This fix is working for me too. |
|
This does work for me. |
|
works for me. tks! |
|
This worked, thank you! For anyone on MacOS, the relevant files were in: |
|
Thanks! Worked for me as well. |
|
i love you |
|
Thanks for the contribution! I wonder if it works for the older version, will do a quick check. Updated: Intuitively, you can pass both |
There was a problem hiding this comment.
Pull request overview
Fixes Overleaf compile requests by sending the root document path (rootResourcePath) instead of the root document Mongo ID (rootDoc_id), resolving the 400 error on save-triggered compiles.
Changes:
- Update
BaseAPI.compile()to accept and sendrootResourcePathin the compile request body. - Resolve the configured root document ID to a workspace path before calling the compile API.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/core/remoteFileSystemProvider.ts | Resolves rootDoc_id to a relative rootResourcePath before compiling. |
| src/api/base.ts | Renames compile parameter and sends rootResourcePath in the POST body. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
If _resolveById fails to resolve the root document ID to a path, fall back to null instead of sending an empty string as rootResourcePath, which would cause a harder-to-diagnose 400 error. Add a console.warn to make the failure visible in logs. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
edkontar
left a comment
There was a problem hiding this comment.
Tried the fix, but I have the remote file system read error:
[Window] Failed to resolve files at location: overleaf-workshop://www.overleaf.com/ProjectName
|
This PR is fully functional and resolves my problems : ) |
Maybe you didn't apply all the two commits? |
|
it works |
yes, it works |
|
thx,what should this be like for Windows version? |
C:\Users.vscode\extensions\iamhyc.overleaf-workshop-0.15.7\out,you can see |
Resolved,for windows users the files are located at: base.js |
thx |
|
Sorry for the late, really busy on the works. I have tested the function both working on community & offical server. Just need one more approval to move it forward. |
Fixes #355
Fix: Compile failure —
rootResourcePath is missing in request bodyProblem
Every time a save is performed, it triggers a compile request that fails with a
400error from Overleaf's API:This causes a permanent red flag in the VS Code status bar and no PDF output in
.output, even though the project compiles successfully on overleaf.com directly.Root Cause
Overleaf's compile API expects a
rootResourcePathfield containing the file path of the root document (e.g."main.tex"). However, the extension was sendingrootDoc_id— a MongoDB document ID (e.g."69c4fd3d5256760243b6e292") — which is a completely different field that the API does not accept as a substitute forrootResourcePath.The bug has two parts:
src/api/base.ts— The compile request body includedrootDoc_idbut never includedrootResourcePath.src/core/remoteFileSystemProvider.ts— Thecompile()method passed the raw MongoDB ID directly to the API without resolving it to a file path first.The ID was available and correct (confirmed via debugging) — it just needed to be resolved to a path using the existing
_resolveById()method before being sent.Fix
src/api/base.ts— AddrootResourcePathto the compile request body (the parameter is renamed accordingly):src/core/remoteFileSystemProvider.ts— Resolve the MongoDB ID to a file path before calling the API:The
.replace(/^\//, '')strips the leading/from the path returned by_resolveById(), giving a clean relative path likemain.texrather than/main.tex.Testing
Verified locally on:
0.15.71.113.0(x64,.debinstall on Ubuntu Linux)www.overleaf.com(official server)After the fix, saving a
.texfile triggers a successful compile, the PDF appears in.output, and the red flag is gone.Notes
rootDoc_idfield in the request body has been removed since it was never a valid field for Overleaf's compile API — onlyrootResourcePathis required.rootResourcePathresolves tonull(no root doc set), the compile request omits it, which matches the previous behaviour.