Accept storage type names case-insensitively in the management API#5036
Accept storage type names case-insensitively in the management API#5036Zhuoxi2000 wants to merge 1 commit into
Conversation
dimas-b
left a comment
There was a problem hiding this comment.
Thanks for your contribution, @Zhuoxi2000 !
| FILE: "#/components/schemas/FileStorageConfigInfo" | ||
| # Lowercase aliases: the server accepts storage type names | ||
| # case-insensitively (https://github.com/apache/polaris/issues/996) | ||
| s3: "#/components/schemas/AwsStorageConfigInfo" |
There was a problem hiding this comment.
I'm not sure duplicating discriminator values in the spec is a sustainable impl. approach 🤔
Creating a catalog with "storageType": "s3" failed while "S3" succeeded. The storage config discriminator is both a Jackson polymorphic type id and a visible enum property, and both matched case-sensitively. Rather than enumerate lowercase aliases per type (which would have to be repeated in the spec for every discriminator and every enum), this enables two standard Jackson features on the shared ObjectMapper: - ACCEPT_CASE_INSENSITIVE_VALUES — case-insensitive polymorphic type id (subtype discriminator) matching, and - ACCEPT_CASE_INSENSITIVE_ENUMS — case-insensitive enum value matching (needed as well because the discriminator is declared visible=true and is deserialized into the enum after subtype dispatch). Both are required for the storage config case; together they make the whole API lenient about input case without any per-type wiring, so new enums and discriminators are covered automatically. Only input is relaxed: serialization still emits the canonical value and unknown values are still rejected. Fixes apache#996
72c5174 to
63bc479
Compare
Good point thanks for calling this out. @dimas-b I reworked the change so we don’t need to duplicate aliases in the spec anymore. the shared One thing to note: because this uses the shared Quarkus The PR is now just a small |
|
Thanks for your contribution. I'd recommend to take a look at this discussion about case-sensitivity. |
| * leniency is uniform across the API rather than special-cased per type — which is what keeps it | ||
| * maintainable as new enums and discriminators are added. | ||
| */ | ||
| @Singleton |
There was a problem hiding this comment.
IIUC, this annotation would make Quarkus finds it on its own and slaps it on the ONE shared ObjectMapper the whole app uses. That means it not only just turn on lowercase for management API, but also turns on for Iceberg REST too, quietly.
IMO, we should it lock it to management API scope.
There was a problem hiding this comment.
Yes, we should be careful with the impact of default JSON serializer config changes. We certainly should not automatically apply this to the Iceberg REST API.
| - Names containing any of these characters: <code>/\:*?"<>|#+`</code> | ||
|
|
||
| ### New Features | ||
| - Request enums and polymorphic type ids are now accepted case-insensitively — e.g. `"storageType": "s3"` is accepted alongside the canonical `"S3"`, as are all other request enums (catalog `type`, `connectionType`, `authenticationType`, …). Responses always emit the canonical value and unknown values are still rejected. |
There was a problem hiding this comment.
nit: do we have connectionType and authenticationType exercised as well?
| @Override | ||
| public void customize(ObjectMapper objectMapper) { | ||
| objectMapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_VALUES, true); | ||
| objectMapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true); |
There was a problem hiding this comment.
Could you also reply to the related dev thread mentioning this PR for the sake of community awareness?
https://lists.apache.org/thread/jx2dn3fztn3t7tnnz8q7tg9l3v0orksy
Fixes #996
Problem
"storageType": "s3"is rejected while"S3"works: both the Jacksonsubtype discriminator on
StorageConfigInfoand the generated enum matchcase-sensitively.
Changes
spec/polaris-management-service.yml: the discriminator mapping now listslowercase aliases (
s3,gcs,azure,file), so subtype resolutionaccepts them and the published spec documents both spellings.
server-templates/enumClass.mustache(new override, based onopenapi-generator's
JavaJaxRS/resteasytemplate): generated enums gain acase-insensitive
@JsonCreator fromValue, covering the visiblediscriminator property and all other request enums consistently.
Responses always emit the canonical uppercase value; unknown values are
still rejected.
Testing
Extended
CatalogSerializationTest: all four storage types in bothspellings resolve to the correct subclass; lowercase input round-trips to
the canonical enum and serializes back as
"S3"; unknown values stillthrow.
Note for reviewers
@JsonSubTypes.Type(names = {...})via the generator'slambda.lowercasewas considered first, but that lambda escapes reserved words
(
FILE→_file), so the explicit spec mapping is safer andself-documenting. The Python client picks up the aliases on its next
regeneration; existing clients are unaffected.
Checklist
CHANGELOG.md(if needed)site/content/in-dev/unreleased(if needed)