Skip to content

OpenAPI: Mark StructField doc as nullable in REST catalog spec#16070

Open
Amneet13 wants to merge 1 commit intoapache:mainfrom
Amneet13:amneet13/support-null-docs
Open

OpenAPI: Mark StructField doc as nullable in REST catalog spec#16070
Amneet13 wants to merge 1 commit intoapache:mainfrom
Amneet13:amneet13/support-null-docs

Conversation

@Amneet13
Copy link
Copy Markdown

Problem

The doc field in the StructField schema in rest-catalog-open-api.yaml was missing nullable: true. However, the Java implementation in Types.NestedField has always allowed doc to be null — it defaults to null (see Types.java line 761) and the doc() getter can return null.

This mismatch means clients that auto-generate code from the OpenAPI spec would incorrectly treat doc as a required non-null string, potentially causing deserialization failures when the server returns a StructField with no doc value.

Change

Added nullable: true to the doc field in the StructField schema to align the spec with the actual Java behavior.

References

  • api/src/main/java/org/apache/iceberg/types/Types.java#L761
  • open-api/rest-catalog-open-api.yaml#L2294

Comment on lines 2294 to +2296
doc:
type: string
nullable: true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this optional ?

if (field.doc() != null) {
generator.writeStringField(DOC, field.doc());
}

while sending to server this is omitted ? i know while reading i.e fromJson we are null tolerant but i think its fine

Copy link
Copy Markdown
Author

@Amneet13 Amneet13 Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@singhpk234 Thanks for the review! You're right that the Iceberg serializer omits doc when it's null. However, we ran into a real-world case where an Iceberg table is created on top of a Paimon table — in that scenario doc is explicitly sent as null (not omitted) in the response. This causes deserialization failures in clients auto-generated from the OpenAPI spec since the spec didn't allow null. Adding nullable: true makes the spec tolerant of both cases — absent and explicitly null — which is the safer contract for external clients.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants