Repository navigation
Fixes 36413: Return 400 for malformed entity names - #36414
Conversation
Code Review ✅ Approved🟡 Medium risk · Centralizing FQN parse failures as IllegalArgumentException changes malformed-name handling across endpoints; affected requests could now receive 400 instead of 500. Parses malformed fully qualified names into a clear VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
🚦 Removed from the merge queue —
|
🚦 Removed from the merge queue —
|
…) (#36415) * Fixes 36413: Return 400 for malformed entity names * Mark new FQN parse locals final
Fixes #36413
Problem
When a request passes an entity name the server cannot parse, the API answers with HTTP 500. For example,
GET /api/v1/tables/name/"returns:{"code":500,"errorType":"UNHANDLED_SERVER_EXCEPTION","message":"An exception with message [null] was thrown while processing request."}This affects every
/name/{fqn}endpoint, and every query parameter that takes a name (domain,team,user,fqn, and so on). The bad input is the caller's mistake, so the right answer is 400 with a message that says what is wrong.Security scanners such as OWASP ZAP flag these 500s as possible SQL injection, because an odd input causing a server error is what they look for. The input never reaches SQL: names are hashed before any query runs.
Why it happened
Before looking an entity up, the server parses its fully qualified name (FQN) to split it into parts and hash it. The parser stops on malformed input, such as an unbalanced quote or an empty segment, by throwing ANTLR's
ParseCancellationException. Nothing translated that exception, so the generic exception mapper reported it as an unhandled server error, with anullmessage.What this PR changes
All FQN parsing goes through one method, so the fix lives there. When the parser bails, that method now throws
IllegalArgumentException("Invalid fully qualified name <input>")and keeps the parser exception as the cause. The exception mapper already turnsIllegalArgumentExceptioninto a 400, the same way it handles other invalid names, so no resource code changes.The three places that caught
ParseCancellationExceptionthemselves (isValid, the round-trip check behindvalidateFqnName, and dot-path parsing inFieldPathUtils) now catch the new exception, so they behave exactly as before. Nothing in OpenMetadata or Collate depends on the old exception type.What users will notice
400 Invalid fully qualified name "instead of a 500 with no message.How it was tested
FullyQualifiedNameTest: six malformed inputs, including a lone"and an unbalanced quote, now throw the new exception with the expected message and cause, andbuildHashandisValidhandle the scanner's input. All 827 tests in theutilpackage pass.BaseEntityIT.get_entityByMalformedName_400: a real server returns 400 forGET .../name/". It ran and passed for all 63 entity types on MySQL + Elasticsearch.ParseCancellationExceptionfromFullyQualifiedName.buildHash.Not in this PR
/api/v1/search/aggregatealso returns 500 for a value with an unbalanced quote, because OpenSearch rejects the query. That is a separate cause and needs its own fix.The shared malformed-name test still needs correction before merging.
Findings
Summary
Malformed fully qualified names now throw
IllegalArgumentExceptionwith a clear message and the original parser exception as the cause.Reviews (2) · Last reviewed commit: "Mark new FQN parse locals final" · Reviewed by Greptile