rusackas commented on code in PR #42489:
URL: https://github.com/apache/superset/pull/42489#discussion_r4077857390
##########
superset-frontend/packages/superset-ui-core/src/query/getClientErrorObject.ts:
##########
@@ -88,7 +88,14 @@ const ERROR_CODE_LOOKUP = {
};
export function checkForHtml(str: string): boolean {
- return !isJsonString(str) && isProbablyHTML(str);
+ // An HTML error page served by a proxy or gateway begins with markup, and
+ // has no message worth showing. A server-authored error that merely quotes
+ // a tag — a database syntax error echoing back the offending `<a>`, say —
+ // begins with prose, and is the whole point of the response. Only the
+ // former may be collapsed into a generic status message.
+ return (
+ !isJsonString(str) && str.trimStart().startsWith('<') &&
isProbablyHTML(str)
+ );
Review Comment:
Pushed a fix for this in `bd281ae6ef`. The gap was exactly what CodeAnt
flagged: `isProbablyHTML()`'s `DOMParser` auto-closes stray tags on parse, so
it can't distinguish a real fragment from a message that merely opens with a
quoted, unclosed tag like `<a> is not valid syntax`.
Rather than requiring doctype/document markup (which would break the
existing bare-`<div>...</div>` fragment tests), `checkForHtml()` now requires
the *leading* tag to actually close somewhere in the source string before
treating it as a page: `<div>500: Internal Server Error</div>` closes what it
opens, `<a> is not valid syntax` doesn't. The `<!doctype html>` preamble case
is exempted since `isProbablyHTML()` already gates that on its own.
Added a regression test for the exact case from this thread (`<a> is not
valid syntax`). All 279 tests across `packages/superset-ui-core/test/query`,
`utils/html.test.tsx`, and `asyncEvent.test.ts` pass.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]