Skip to content

Fixes 36413: Return 400 for malformed entity names - #36414

Merged
manerow merged 2 commits into
mainfrom
fix/invalid-fqn-returns-400
Oct 29, 2026
Merged

manerow merged 2 commits into
mainfrom
fix/invalid-fqn-returns-400

Conversation

@manerow

@manerow manerow commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

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 a null message.

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 turns IllegalArgumentException into a 400, the same way it handles other invalid names, so no resource code changes.

The three places that caught ParseCancellationException themselves (isValid, the round-trip check behind validateFqnName, and dot-path parsing in FieldPathUtils) 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

  • A malformed name now returns 400 Invalid fully qualified name " instead of a 500 with no message.
  • Valid names, including quoted names that contain dots or quotes, behave as before.
  • If an FQN already stored in the database cannot be parsed (for example, legacy corrupt data), the request that reads it now fails with 400 instead of 500. That data was already unreadable; only the status code changes.

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, and buildHash and isValid handle the scanner's input. All 827 tests in the util package pass.
  • New BaseEntityIT.get_entityByMalformedName_400: a real server returns 400 for GET .../name/". It ran and passed for all 63 entity types on MySQL + Elasticsearch.
  • Before the fix, the same requests against a local build returned 500, and the server log showed the ParseCancellationException from FullyQualifiedName.buildHash.

Not in this PR

  • /api/v1/search/aggregate also returns 500 for a value with an unbalanced quote, because OpenSearch rejects the query. That is a separate cause and needs its own fix.
  • Backport to 2.1 follows in a separate PR.

RetriggerView in GreptileConfidence Score: 4/5

The shared malformed-name test still needs correction before merging.

Findings

  1. P1 Shared test expects wrong status ▶

Summary

Malformed fully qualified names now throw IllegalArgumentException with a clear message and the original parser exception as the cause.

  • Malformed entity names now return a clear bad-request response.

Reviews (2) · Last reviewed commit: "Mark new FQN parse locals final" · Reviewed by Greptile

@manerow manerow self-assigned this Oct 28, 2026
@manerow
manerow requested a review from a team as a code owner October 28, 2026 08:12
@manerow
manerow requested a review from harshach October 28, 2026 08:12
@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels Oct 28, 2026
@gitar-bot

gitar-bot Bot commented Oct 28, 2026

Copy link
Copy Markdown
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 IllegalArgumentException instead of an unhandled ParseCancellationException, so /name/{fqn} endpoints and name query parameters return HTTP 400 rather than 500. Existing callers that catch the parser exception are updated to catch the new type, and no open issues were found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@manerow
manerow added this pull request to the merge queue Oct 28, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-10-28T15:13:50Z)

Blocked the queue: integration-tests-mysql-elasticsearch

@manerow
manerow added this pull request to the merge queue Oct 28, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-10-28T19:56:12Z)

Blocked the queue: integration-tests-postgres-opensearch

@manerow
manerow added this pull request to the merge queue Oct 29, 2026
Merged via the queue into main with commit caaf979 Oct 29, 2026
104 of 105 checks passed
@manerow
manerow deleted the fix/invalid-fqn-returns-400 branch October 29, 2026 13:30
manerow added a commit that referenced this pull request Oct 29, 2026
…) (#36415)

* Fixes 36413: Return 400 for malformed entity names

* Mark new FQN parse locals final
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Malformed entity names in API requests return 500 instead of 400

2 participants