antiwork/gumroad · warning · ResponseError
Something went wrong.
Error message
Something went wrong.
What it means
deleteAutocompleteSearch() throws at line 20 when DELETE discover_search_autocomplete_path(data) returns 4xx — removing one entry from the signed-in user's Discover recent searches. The whole data object is passed as route params, so a blank/absent query produces a route the router will not match or the controller rejects; expired sessions (401) and CSRF failures on DELETE also land here. Impact is cosmetic — a suggestion entry — so warning severity.
Source
Thrown at app/javascript/data/discover.ts:20
export type AutocompleteSearchResults = {
products: {
name: string;
url: string;
seller_name: string | null;
thumbnail_url: string | null;
}[];
recent_searches: string[];
viewed?: boolean;
};
export async function deleteAutocompleteSearch(data: { query: string }) {
const response = await request({
method: "DELETE",
accept: "json",
url: Routes.discover_search_autocomplete_path(data),
});
if (!response.ok) throw new ResponseError();
}
View on GitHub (pinned to afeacbd394)
Solutions
- Trim and require a non-empty query before firing the request
- Treat failure as non-fatal: remove the entry locally — the server list reconverges on next page load
- If entries keep reappearing, check DevTools: the DELETEs are 401/404, not succeeding
- Re-login when every authenticated call on the page fails
Example fix
// before
deleteAutocompleteSearch({ query }).catch(() => {});
// after
if (!query.trim()) return;
setRecentSearches((prev) => prev.filter((q) => q !== query)); // optimistic
deleteAutocompleteSearch({ query: query.trim() }).catch(() => {/* self-heals on next load */}); Defensive patterns
Strategy: fallback
Validate before calling
const q = query.trim(); if (!q) return; // empty query cannot match the route — skip the request entirely
Type guard
const isResponseError = (e: unknown): e is ResponseError => e instanceof ResponseError;
Try / catch
setRecentSearches((prev) => prev.filter((s) => s !== query)); // optimistic update first
deleteAutocompleteSearch({ query: query.trim() }).catch(() => {
// non-fatal: server history reconverges on next page load
}); Prevention
- Never fire the DELETE with an empty or whitespace query — route generation will not match
- Update local state first and treat server failure as cosmetic drift
- Do not build error UI for this call; log quietly if entries reappear persistently
- Re-login when every authenticated request on the page starts failing
When it happens
Trigger: query empty or whitespace so route generation fails (404/422); session expired so no recent-search store exists (401); DELETE sent without a valid CSRF token; duplicate deletes racing the first (404).
Common situations: A 'clear' UI firing one DELETE per entry while the user navigates away; test harness without cookies; stale state submitting the empty search box.
Related errors
- Something went wrong.
- Something went wrong.
- ${response.message}
- Something went wrong.
- Something went wrong.
AI-assisted analysis of antiwork/gumroad@afeacbd394 (2026-08-21).
Data as JSON: /api/errors/b68014878d55e7cc.
Report an issue: GitHub.