Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
darix opened this issue May 18, 2024 · 3 comments
Milestone

Comments

@darix
Copy link

darix commented May 18, 2024

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)
 					}
 				}
 

@darix
Copy link
Author

darix commented May 18, 2024

alternatively the error could bubble up to the caller location to make it easier to find the line location that caused this.

Encountered error "Forbidden" while fetching tweet ...

@darix
Copy link
Author

darix commented May 20, 2024

if we would let it bubble up it would also give the possibility to say "oh if rendering this failed i ignore it" and make the render a noop

@bep bep added this to the v0.127.0 milestone May 30, 2024
@darix
Copy link
Author

darix commented Jun 5, 2024

updated patch for 0.127.0

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

@bep bep modified the milestones: v0.127.0, v0.128.0 Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants