Skip to content

[Bug]: Upload & Publish reports success when the update or publish actually fails #342

Description

@BarisKuzu

What happened?

Upload & Publish reports <file> uploaded. even when the update or the publish actually failed server-side.

If another solution import or publish is running against the environment, Dataverse rejects the PATCH webresourceset(...) and/or the PublishXml request with a non-2xx (the "solution is being imported / publish in progress" style lock errors). The extension shows the green <file> uploaded. notification anyway, and the linker file is left claiming the resource is current. The stale web resource stays live in the org and nothing tells you.

The only reason this is survivable today is that you eventually notice the browser is still running old code.

Root cause

RequestHelper swallows every non-2xx response that isn't exactly Unauthorized.

src/helpers/requestHelper.ts, requestData L48-50, postData L90-92, patchData L131-133 — all three have the same shape:

if (response.ok) {
    return ...;
} else {
    if (response.statusText === "Unauthorized" && this.dvHelper) {
        // ... reAuthenticate + retry
    } else {
        return undefined;   // <-- any other failure is silently discarded
    }
}

So a 400/409/503 resolves to undefined rather than throwing. The caller in src/helpers/webResourceHelper.ts (uploadWebResourceInternal, L438 / L460-462) awaits those calls, never enters its catch, and unconditionally reports success:

await this.dvHelper.updateWebResourceContent(resc["@_Id"], wr);   // can silently no-op
...
await this.dvHelper.publishWebResource(id);                        // can silently no-op
progress.report({ increment: 100 });
vscode.window.showInformationMessage(`${fileName} uploaded.`);     // fires regardless

Note this affects the content update as well as the publish, so "uploaded" can be false on both counts.

This is the same class of bug as #283 (expired token reported as success). That fix added the Unauthorized re-auth branch but left the general else returning undefined, so every other server-side failure is still silent.

Steps to reproduce

  1. Start a solution import (or a large publish-all) on the target environment and leave it running.
  2. In VS Code, right-click a linked web resource → Upload & Publish.
  3. Notification reads myfile.js uploaded.
  4. Check the web resource in the maker portal / hit it in the browser — content is unchanged, or updated but unpublished.

Also reproducible by pointing the connection at an environment where the user lacks the prvPublishWebResource privilege — same false success.

Expected

The failure surfaces: ErrorMessages.wrUploadError (or better, the Dataverse error message/code from the response body) instead of the success toast, and the operation is not recorded as a successful upload.

Suggested fix

In all three RequestHelper methods, replace the silent return undefined with a throw carrying the server's error payload — Dataverse returns a JSON body with error.code / error.message that would make these failures self-diagnosing:

} else {
    const body = await response.text();
    throw new Error(`${response.status} ${response.statusText}: ${body}`);
}

uploadWebResourceInternal's existing catch then does the right thing already. Publish-lock errors in particular have a very readable message that is worth showing verbatim to the user.

Happy to send a PR if you'd like.

What version of the tool are you using?

2.2.8

What version of Visual Studio Code are you running?

1.133.0

Any relevant session id from VSCode?

No response

Relevant log output

No extension-side log is produced — that is part of the problem.
The failed response is discarded before any console.log/appendLine,
so nothing appears in the Output pane or exthost.log.

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions