Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 7, 2025

Problem

When using the "Upload & Publish Web Resource" feature with an expired authentication token or connection timeout, the extension would silently fail and still display a success message to the user. This created confusion as users believed their web resources were uploaded successfully when they actually failed.

In contrast, the "Compare Web Resource" feature properly displayed error messages when encountering authentication or connection issues, which was the expected behavior.

Root Cause

The issue stemmed from two problems in the error handling chain:

  1. requestHelper.ts: The postData() and patchData() methods were catching exceptions but not re-throwing them, causing errors to be silently swallowed
  2. webResourceHelper.ts: The uploadWebResourceInternal() method had no error handling and unconditionally displayed a success message regardless of whether the upload/publish operations succeeded

Solution

This PR implements proper error handling by:

  1. Propagating errors from HTTP operations: Modified postData() and patchData() in requestHelper.ts to re-throw caught exceptions after logging, ensuring errors propagate up the call stack
  2. Adding error handling to upload workflow: Wrapped the upload and publish operations in uploadWebResourceInternal() with a try-catch block that displays a user-friendly error message when operations fail
  3. Adding error message constant: Created ErrorMessages.wrUploadError with a clear message: "Failed to upload web resource. Please check your connection and try again."

Impact

  • ✅ Users now see error messages when authentication tokens expire
  • ✅ Users now see error messages when connection timeouts occur
  • ✅ Success messages only display when operations actually succeed
  • ✅ Behavior is now consistent with the "Compare Web Resource" feature
  • ✅ No breaking changes to existing functionality

Files Changed

  • src/helpers/requestHelper.ts - Added error re-throw in catch blocks (2 methods)
  • src/helpers/webResourceHelper.ts - Added try-catch block with error handling
  • src/utils/ErrorMessages.ts - Added new error message constant

Fixes #[issue_number]

Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug]: Connection timeout does not show error when uploading web resources</issue_title>
<issue_description>### What happened?

When we use Upload & Publish option and the token is expired there is no error from the tool rather it says success. The compare of web resource when the token is expired throws error.

Expected is that the same should happen during Upload nad Publish

What version of the tool are you using?

2.0.5

What version of Visual Studio Code are you running?

No response

Any relevant session id from VSCode?

No response

Relevant log output

```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>
Fixes #283

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits October 7, 2025 18:52
Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com>
Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix connection timeout error on web resource upload Fix: Display error messages when web resource upload fails due to connection timeout or expired token Oct 7, 2025
Copilot AI requested a review from Power-Maverick October 7, 2025 18:57
Copilot finished work on behalf of Power-Maverick October 7, 2025 18:57
@Power-Maverick Power-Maverick marked this pull request as ready for review October 7, 2025 19:27
@Power-Maverick Power-Maverick merged commit 4f6a56e into main Oct 7, 2025
3 checks passed
@Power-Maverick Power-Maverick deleted the copilot/fix-token-expiration-error branch October 7, 2025 21:55
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.

[Bug]: Connection timeout does not show error when uploading web resources

2 participants