Skip to content

fix: if the purge api call fails, include the api response body in the thrown error's message #571

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

Merged
merged 2 commits into from
Mar 4, 2025

Conversation

JakeChampion
Copy link
Contributor

Right now if the purge call returns a non-ok response, the error message does not include the response, which makes it hard for the user of the api to figure out what the issue is

…e thrown error's message
@JakeChampion JakeChampion requested a review from a team as a code owner March 3, 2025 15:32
…the purge api

Prior to this commit, a call to `purgeCache` could supply any combination of siteID, siteSlug,
and domain.
If that does happen then the purge api endpoint as of today will do the following:

- If the request passed in SiteID and either SiteSlug or Domain, then the SiteID would be used
- If the request passed in SiteSlug and Domain, then the SiteSlug would be used

This is likely not what the user is wanting.
I've opened a pull-request in netlify-server to make it return an error response instead,
but I think we can also improve the situation in this package by throwing an earlier error,
one which they the user can spot when developing locally
@JakeChampion JakeChampion merged commit e01516d into main Mar 4, 2025
6 checks passed
@JakeChampion JakeChampion deleted the jake/purge branch March 4, 2025 19:49
JakeChampion pushed a commit that referenced this pull request Mar 17, 2025
🤖 I have created a release *beep* *boop*
---


## [3.0.2](v3.0.1...v3.0.2)
(2025-03-17)


### Bug Fixes

* if the purge api call fails, include the api response body in the
thrown error's message
([#571](#571))
([e01516d](e01516d))
* only purge alias by default if the purgeCache function is called
within a deployed function
([#576](#576))
([964b0a2](964b0a2))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: token-generator-app[bot] <82042599+token-generator-app[bot]@users.noreply.github.com>
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