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

add URI to resource load error #12271

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

0xB10C
Copy link

@0xB10C 0xB10C commented Mar 18, 2024

Previously, only ERROR failed to fetch remote resource: Forbidden would be shown when a resource failed to load. In my case, a tweet's author I was embedding using the twitter shortcode switched his profile to private which resulted in my blog failing to build. To figure out where the originates, I added the log to the error message. This should be useful for others too.

@CLAassistant
Copy link

CLAassistant commented Mar 18, 2024

CLA assistant check
All committers have signed the CLA.

@0xB10C 0xB10C force-pushed the 2024-03-include-uri-in-error-msg branch from cf5d0c1 to 701f555 Compare May 6, 2024 20:14
@0xB10C
Copy link
Author

0xB10C commented May 6, 2024

The CI failure looked unrelated (timeout during CI environment setup). I force-pushed to retrigger the CI, but it requires approval again.

Previouly, only "ERROR failed to fetch remote resource: Forbidden"
would be shown when a resource failed to load. In my case, a tweet's
author I was embedding using the twitter shortcode switched his profile
to private which resulted in my blog failing to build. To figure out
where the originates, I added the log to the error message.
@0xB10C 0xB10C force-pushed the 2024-03-include-uri-in-error-msg branch from 701f555 to 8f78d71 Compare May 8, 2024 09:09
@0xB10C
Copy link
Author

0xB10C commented May 8, 2024

This CI failure looked very related. There seems to be a test that includes the output of a resource load error. Updated that test to match the changes.

error for future refference

CI log

--- FAIL: TestResourceChainBasic (0.08s)
    resource_chain_test.go:103: Test run 0
    resource_chain_test.go:106: 
        error:
          no substring match found
        comment:
          FAILED REMOTE ERROR DETAILS CONTENT: |failed to fetch remote resource: Not Implemented|Body: { msg: failed } not in: 
          
          
          
          
          
          
          <script src="/livereload.js?mindelay=10&amp;v=2&amp;port=&amp;path=livereload" data-no-instant defer></script>HELLO: /hello.html|/hello.fea61a7e7ba8eaf0c4a60a871f68ec8fc044457e12b8f602245eedee623fb063f0e88e47ccf748107485af995911cbda25493d4c7faa824014437cf8a0aaa1a4.min.375690f1152af3649ca0eda5a0686a0bc50a279c2b7fb1af73da088727f65d96.html|<h1>Hello World!</h1>
          
          
          
          
          
          SUNSET: /images/sunset.jpg|/images/sunset.a9bf1d944e19c0f382e0d8f51de690f7d0bc8fa97390c4242a86c3e5c0737e71.jpg|900|90587
          FIT: /images/sunset.jpg|/images/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_200x200_fit_q75_box.jpg|200
          CSS integrity Data first: sha256-od9YaHw8nMOL8mUy97Sy8sKwMV3N4hI3aVmZXATxH&#43;8= /styles.min.a1df58687c3c9cc38bf26532f7b4b2f2c2b0[315](https://github.com/gohugoio/hugo/actions/runs/8975174217/job/24650750324?pr=12271#step:15:316)dcde212376959995c04f11fef.css
          CSS integrity Data last:  /styles2.min.1cfc52986836405d37f9998a63fd6dd8608e8c410e5e3db1daaa30f78bc273ba.css sha256-HPxSmGg2QF03&#43;ZmKY/1t2GCOjEEOXj2x2qow94vCc7o=
          
          
          
          
          
          
          
          
          
          SUNSET REMOTE: /sunset_8772799889021172246.jpg|/sunset_8772799889021172246.a9bf1d944e19c0f382e0d8f51de690f7d0bc8fa97390c4242a86c3e5c0737e71.jpg|900|90587
          FIT REMOTE: /sunset_8772799889021172246.jpg|/sunset_8772799889021172246_hu59e56ffff1bc1d8d122b1403d34e039f_90587_200x200_fit_q75_box.jpg|200
          REMOTE NOT FOUND: OK
          LOCAL NOT FOUND: OK
          PRINT PROTOCOL ERROR1: error calling resources.GetRemote: Get "gopher://example.org": unsupported protocol scheme "gopher"
          PRINT PROTOCOL ERROR2: error calling resources.GetRemote: Get "gopher://example.org": unsupported protocol scheme "gopher"
          PRINT PROTOCOL ERROR DETAILS: Err: error calling resources.GetRemote: Get "gopher://example.org": unsupported protocol scheme "gopher"||
          FAILED REMOTE ERROR DETAILS CONTENT: |failed to fetch remote resource from &#39;http://127.0.0.1:42757/fail.jpg&#39;: Not Implemented|Body: { msg: failed }
          |StatusCode: 501|ContentLength: 16|ContentType: text/plain; charset=utf-8|
        container:
          "\n\n\n\n\n\n<script src=\"/livereload.js?mindelay=10&amp;v=2&amp;port=&amp;path=livereload\" data-no-instant defer></script>HELLO: /hello.html|/hello.fea61a7e7ba8eaf0c4a60a871f68ec8fc044457e12b8f602245eedee623fb063f0e88e47ccf748107485af995911cbda25493d4c7faa824014437cf8a0aaa1a4.min.375690f1152af3649ca0eda5a0686a0bc50a279c2b7fb1af73da088727f65d96.html|<h1>Hello World!</h1>\n\n\n\n\n\nSUNSET: /images/sunset.jpg|/images/sunset.a9bf1d944e19c0f382e0d8f51de690f7d0bc8fa97390c4242a86c3e5c0737e71.jpg|900|90587\nFIT: /images/sunset.jpg|/images/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_200x200_fit_q75_box.jpg|200\nCSS integrity Data first: sha256-od9YaHw8nMOL8mUy97Sy8sKwMV3N4hI3aVmZXATxH&#43;8= /styles.min.a1df58687c3c9cc38bf26532f7b4b2f2c2b0315dcde212376959995c04f11fef.css\nCSS integrity Data last:  /styles2.min.1cfc52986836405d37f9998a63fd6dd8608e8c410e5e3db1daaa30f78bc273ba.css sha256-HPxSmGg2QF03&#43;ZmKY/1t2GCOjEEOXj2x2qow94vCc7o=\n\n\n\n\n\n\n\n\n\nSUNSET REMOTE: /sunset_8772799889021172246.jpg|/sunset_8772799889021172246.a9bf1d944e19c0f382e0d8f51de690f7d0bc8fa97390c4242a86c3e5c0737e71.jpg|900|90587\nFIT REMOTE: /sunset_8772799889021172246.jpg|/sunset_8772799889021172246_hu59e56ffff1bc1d8d122b1403d34e039f_90587_200x200_fit_q75_box.jpg|200\nREMOTE NOT FOUND: OK\nLOCAL NOT FOUND: OK\nPRINT PROTOCOL ERROR1: error calling resources.GetRemote: Get \"gopher://example.org\": unsupported protocol scheme \"gopher\"\nPRINT PROTOCOL ERROR2: error calling resources.GetRemote: Get \"gopher://example.org\": unsupported protocol scheme \"gopher\"\nPRINT PROTOCOL ERROR DETAILS: Err: error calling resources.GetRemote: Get \"gopher://example.org\": unsupported protocol scheme \"gopher\"||\nFAILED REMOTE ERROR DETAILS CONTENT: |failed to fetch remote resource from &#39;http://127.0.0.1:42757/fail.jpg&#39;: Not Implemented|Body: { msg: failed }\n|StatusCode: 501|ContentLength: 16|ContentType: text/plain; charset=utf-8|\n"
        want:
          "FAILED REMOTE ERROR DETAILS CONTENT: |failed to fetch remote resource: Not Implemented|Body: { msg: failed }"
        stack:
          /home/runner/work/hugo/hugo/hugolib/testhelpers_test.go:756
            s.Assert(content, qt.Contains, match, qt.Commentf(match+" not in: \n"+content))
          /home/runner/work/hugo/hugo/hugolib/resource_chain_test.go:106
            b.AssertFileContent("public/index.html",
                fmt.Sprintf(`
            SUNSET: /images/sunset.jpg|/images/sunset.a9bf1d944e19c0f382e0d8f51de690f7d0bc8fa97390c4242a86c3e5c0737e71.jpg|900|90587
            FIT: /images/sunset.jpg|/images/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_200x200_fit_q75_box.jpg|200
            CSS integrity Data first: sha256-od9YaHw8nMOL8mUy97Sy8sKwMV3N4hI3aVmZXATxH&#43;8= /styles.min.a1df58687c3c9cc38bf26532f7b4b2f2c2b0315dcde212376959995c04f11fef.css
            CSS integrity Data last:  /styles2.min.1cfc52986836405d37f9998a63fd6dd8608e8c410e5e3db1daaa30f78bc273ba.css sha256-HPxSmGg2QF03&#43;ZmKY/1t2GCOjEEOXj2x2qow94vCc7o=
            
            SUNSET REMOTE: /sunset_%[1]s.jpg|/sunset_%[1]s.a9bf1d944e19c0f382e0d8f51de690f7d0bc8fa97390c4242a86c3e5c0737e71.jpg|900|90587
            FIT REMOTE: /sunset_%[1]s.jpg|/sunset_%[1]s_hu59e56ffff1bc1d8d122b1403d34e039f_90587_200x200_fit_q75_box.jpg|200
            REMOTE NOT FOUND: OK
            LOCAL NOT FOUND: OK
            PRINT PROTOCOL ERROR DETAILS: Err: error calling resources.GetRemote: Get "gopher://example.org": unsupported protocol scheme "gopher"||
            FAILED REMOTE ERROR DETAILS CONTENT: |failed to fetch remote resource: Not Implemented|Body: { msg: failed }
            |StatusCode: 501|ContentLength: 16|ContentType: text/plain; charset=utf-8|
            
            
            `, identity.HashString(ts.URL+"/sunset.jpg", map[string]any{})))

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.

None yet

2 participants