Skip to content

[Server] Accept a capitalized boolean for the native REST query parameters - #1897

Closed
moomindani wants to merge 1 commit into
unitycatalog:mainfrom
moomindani:fix/native-boolean-query-params
Closed

moomindani wants to merge 1 commit into
unitycatalog:mainfrom
moomindani:fix/native-boolean-query-params

Conversation

@moomindani

Copy link
Copy Markdown
Contributor

PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

Description of changes

Fixes #1891.

Every query parameter the OpenAPI spec types as a boolean rejected True / False with a 400. Armeria converts a Boolean parameter through a fixed table of true|TRUE|1 and false|FALSE|0, so a capitalized spelling never converted:

$ curl -X DELETE 'http://localhost:8080/api/2.1/unity-catalog/catalogs/c?force=True'
400 {"error_code":"INVALID_ARGUMENT","message":"Can't convert 'True' to type 'Boolean'."}

True is what a hand-written Python client sends -- requests.delete(url, params={"force": True}) renders the query as force=True. force is the parameter that matters: it is acted on, it decides whether a delete cascades, and a caller who spells it that way gets a 400 instead of the delete they asked for. The generated Python client in this repo is unaffected, because its parameters_to_url_query lowercases booleans, so this reaches scripts written directly against the REST API.

Technical changes

  • ValidationUtils.parseBooleanParam reads a query parameter typed as a boolean: true and false without regard to case, plus the 1 / 0 Armeria already converted, so the accepted set only grows and no existing caller changes. An empty value stays what it is today, absent. Anything else is a 400 naming the parameter and the offending value.
  • Ten parameters bind as Optional<String> and convert through that helper: force on the six deletes (catalogs, schemas, functions, models, credentials, external locations), include_browse on both volume read handlers, and omit_properties / omit_columns on listTables.
  • TestUtils gains sendRawGet / sendRawDelete over the existing raw-request sender.

Armeria's conversion cannot be replaced globally: AnnotatedServiceTypeUtil looks Boolean up in a fixed map of types and only falls back to a type's own of / valueOf / fromString for classes outside it, and AnnotatedValueResolver is in an internal package. So the conversion has to move into the handlers, and one shared helper keeps it in a single place rather than ten copies. The same defect on the Iceberg REST surface (purgeRequested on dropTable) is fixed in #1890, which is independent of this PR; whichever merges first, the other switches to the shared helper.

Compatibility: the spec is unchanged -- it types these parameters as boolean already, which is why a capitalized spelling is a valid request. Every spelling accepted before is still accepted, so this is purely additive.

Tests (server/src/test/java/io/unitycatalog/server/service/BooleanQueryParamTest.java)

The cases go over raw HTTP, because the generated client cannot send the values under test. They pin that the value is read, not merely accepted: force=False refuses to delete a catalog that holds a schema while force=True cascades it, and omit_columns / omit_properties decide what the table listing carries. All four tests fail on the unfixed handlers.

build/sbt "server/testOnly io.unitycatalog.server.service.BooleanQueryParamTest"   # 4 passed
build/sbt -J-Xmx2G "server/test"   # 507 passed, 1 pre-existing env failure (GCP credentials), 2 skipped

This pull request and its description were written by Isaac.

…eters

Armeria converts a Boolean query parameter through a fixed table of true|TRUE|1
and false|FALSE|0, so every parameter the OpenAPI spec types as a boolean was
answered 400 "Can't convert 'True' to type 'Boolean'". True and False are what a
hand-written Python client sends: requests renders a Python bool that way. The
parameter that matters is force -- it decides whether a delete cascades, so a
caller who spells it True gets a 400 instead of the delete they asked for.

Ten parameters were affected: force on the six deletes (catalogs, schemas,
functions, models, credentials, external locations), include_browse on both
volume read handlers, and omit_properties / omit_columns on listTables. They now
bind as Optional<String> and convert through ValidationUtils.parseBooleanParam,
which reads true and false without regard to case. The spellings Armeria already
converted, 1 and 0 included, keep working, so the accepted set only grows and no
existing caller changes. A value that is not a boolean at all stays a 400, with a
message that names the parameter and the offending value.

Armeria's conversion cannot be replaced globally: AnnotatedServiceTypeUtil looks
up Boolean in a fixed map of types and only falls back to a type's own of /
valueOf / fromString for classes outside it, and AnnotatedValueResolver is in an
internal package. So the conversion has to move into the handlers, and one shared
helper keeps it in a single place rather than ten copies.

The spec is unchanged: it types these parameters as boolean already, which is why
a capitalized spelling is a valid request.

The tests go over raw HTTP, because the generated client cannot send the values
under test -- its parameters_to_url_query lowercases a boolean. They pin that the
value is read rather than merely accepted: force=False refuses to delete a catalog
that holds a schema while force=True cascades it, and omit_columns /
omit_properties decide what the table listing carries. All four fail on the
unfixed handlers.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Noritaka Sekiyama <[email protected]>
@yili-db

yili-db commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

Should the native REST API accept True/False at all? I don't think it should.

For this surface all.yaml is the source of truth, and it types these as type: boolean, which serializes true/false. True isn't a spelling of that; it's a client handing Python's str(True) to requests. So this isn't "the spec allows a capitalized spelling," it's us accepting input the spec doesn't describe, permanently (we can't walk it back) and unwritten-down (OpenAPI can't express a case-insensitive boolean). Our own generated clients already send true/false; the only thing this helps is a client serializing booleans wrong, and accepting it just hides that bug until it hits a spec-conformant gateway or validator.

@moomindani

Copy link
Copy Markdown
Contributor Author

You are right, and I am closing this.

all.yaml types these as boolean, and True is not a spelling of that -- it is a client handing
Python's str(True) to requests. Accepting it would put an undocumented input into the API
permanently, in a form OpenAPI cannot express, and the only client it helps is one serializing
booleans wrongly; the repository's own generated clients already send true/false.

This is also the line I drew myself when I split it out of #1890: that one was an interop bug, where
pyiceberg cannot drop or purge a table at all because it is pyiceberg that spells the value, and the
Iceberg REST spec is the contract being met. Here the contract is ours, and it says true/false.

Closing #1891 with the same reasoning.

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.

[Server] Boolean query parameters reject the capitalized spelling a hand-written client sends

2 participants