godaddy-wordpress / godaddy-wordpress/coblocks
ISBAT receive consistent error notices using Gist block
- Dominant language
- JavaScript
- Stars
- 794
- Forks
- 142
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
When a request returns as a 404 the Gist block becomes unusable. The block should be improved by adding proper error handling using the existing error notice mechanism.
The Gist block is generating an error when applying a URL with a Gist file.

Original URL
`https://gist.github.com/AnthonyLedesma/33ad1a8cd86da3b6bddbdefa432cb51d#file-gistblocktest-text` (Returns 200)
Transformed request
`https://gist.github.com/AnthonyLedesma/33ad1a8cd86da3b6bddbdefa432cb51d.json?callback=embed_gist_callback_NaN&file=gistblocktest.text` (Returns 404)
**To Reproduce**
Steps to reproduce the behavior:
1. Copy a Gist URL with a file.
* EG( https://gist.github.com/AnthonyLedesma/33ad1a8cd86da3b6bddbdefa432cb51d#file-gistblocktest-text )
2. Add Gist block to a page.
3. Paste the Gist URL with a file into the Gist block.
4. See error.
**Screenshots**
**Gist URL without file**

**Gist URL with file and error returned from Github**

**Expected behavior**
Expect Gist block to properly load Gist files when a correct URL is provided. Expect Gist block to provide useful error notices and recover from invalid attributes.
**Isolating the problem:**
- This bug happens with no other plugins activated
- This bug happens with a default WordPress theme active
- This bug happens **without** the Gutenberg plugin active
- I can reproduce this bug consistently using the steps above
**WordPress Version**
What version of WordPress are you using?
5.3.2
**Gutenberg Version**
What version of the Gutenberg plugin are you using? (If any)
N/A (Also happens with 7.4) active.
**Side note**
I found it interesting that raw transforms properly handles both cases of URL **with** and **without** a file present. See Gif below.

Contributor guide
Assessment
This issue has not been assessed yet.