Repository navigation
[Server] Accept a capitalized boolean for the native REST query parameters - #1897
moomindani wants to merge 1 commit into
Conversation
…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]>
|
Should the native REST API accept For this surface |
|
You are right, and I am closing this.
This is also the line I drew myself when I split it out of #1890: that one was an interop bug, where Closing #1891 with the same reasoning. |
PR Checklist
docsis updatedDescription of changes
Fixes #1891.
Every query parameter the OpenAPI spec types as a
booleanrejectedTrue/Falsewith a 400. Armeria converts aBooleanparameter through a fixed table oftrue|TRUE|1andfalse|FALSE|0, so a capitalized spelling never converted:Trueis what a hand-written Python client sends --requests.delete(url, params={"force": True})renders the query asforce=True.forceis 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 itsparameters_to_url_querylowercases booleans, so this reaches scripts written directly against the REST API.Technical changes
ValidationUtils.parseBooleanParamreads a query parameter typed as a boolean:trueandfalsewithout regard to case, plus the1/0Armeria 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.Optional<String>and convert through that helper:forceon the six deletes (catalogs, schemas, functions, models, credentials, external locations),include_browseon both volume read handlers, andomit_properties/omit_columnsonlistTables.TestUtilsgainssendRawGet/sendRawDeleteover the existing raw-request sender.Armeria's conversion cannot be replaced globally:
AnnotatedServiceTypeUtillooksBooleanup in a fixed map of types and only falls back to a type's ownof/valueOf/fromStringfor classes outside it, andAnnotatedValueResolveris in aninternalpackage. 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 (purgeRequestedondropTable) 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
booleanalready, 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=Falserefuses to delete a catalog that holds a schema whileforce=Truecascades it, andomit_columns/omit_propertiesdecide what the table listing carries. All four tests fail on the unfixed handlers.This pull request and its description were written by Isaac.