Skip to content

Make the error message for "ERROR failed to fetch remote resource: Forbidden" more useful #12518

Open
@darix

Description

@darix

At least including the uri in the error message would help the user to figure out which resources they need to fix.

Locally I applied this patch to get some ideas what we have to fix as Twitter gave us some 403.

diff --git a/resources/resource_factories/create/remote.go b/resources/resource_factories/create/remote.go
index c2d17e7a5..9424fc5a0 100644
--- a/resources/resource_factories/create/remote.go
+++ b/resources/resource_factories/create/remote.go
@@ -138,7 +138,7 @@ func (c *Client) FromRemote(uri string, optionsm map[string]any) (resource.Resou
 
 				if res.StatusCode != http.StatusNotFound {
 					if res.StatusCode < 200 || res.StatusCode > 299 {
-						return nil, temporaryHTTPStatusCodes[res.StatusCode], toHTTPError(fmt.Errorf("failed to fetch remote resource: %s", http.StatusText(res.StatusCode)), res, !isHeadMethod)
+						return nil, temporaryHTTPStatusCodes[res.StatusCode], toHTTPError(fmt.Errorf("failed to fetch remote resource '%s': %s", uri, http.StatusText(res.StatusCode)), res, !isHeadMethod)
 					}
 				}
 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions