Skip to content

Fix nullable UUID type mismatch in Go code generator#4172

Merged
nogates merged 2 commits into
masterfrom
nogates/fix-nullable-uuid-template
Jun 1, 2026
Merged

Fix nullable UUID type mismatch in Go code generator#4172
nogates merged 2 commits into
masterfrom
nogates/fix-nullable-uuid-template

Conversation

@nogates
Copy link
Copy Markdown
Contributor

@nogates nogates commented May 29, 2026

Summary

  • Nullable UUID fields (format: uuid + nullable: true) were being mapped to NullableString in formatter.py, causing generated getter/setter methods to return *string while the method signatures expected uuid.UUID — resulting in compile errors.
  • Added a dedicated NullableUUID struct to utils.j2 (matching the pattern of NullableBool, NullableString, NullableTime, etc.).
  • Updated formatter.py line 158 to emit NullableUUID / NewNullableUUID for nullable uuid fields instead of NullableString.

Example compile errors this fixes (from datadog-api-spec PR #5821 CI run):

model_incident_rule_data_attributes_request.go:191: cannot use *o.IncidentTypeUuid.Get() (variable of type string) as uuid.UUID value in return statement
model_incident_rule_data_attributes_request.go:201: cannot use o.IncidentTypeUuid.Get() (value of type *string) as *uuid.UUID value in return statement
model_incident_rule_data_attributes_request.go:211: cannot use &v (value of type *uuid.UUID) as *string value in argument to o.IncidentTypeUuid.Set

Test plan

  • Regenerate client with a spec that contains a nullable uuid field and confirm the generated code compiles without type errors.
  • Confirm NullableUUID marshal/unmarshal round-trips correctly (JSON UUID strings ↔ uuid.UUID).

🤖 Generated with Claude Code

Nullable UUID fields (format: uuid, nullable: true) were being mapped to
NullableString, causing getter/setter methods to return *string while
the method signatures expected uuid.UUID — a compile error.

Add a dedicated NullableUUID type to utils.j2 and update formatter.py
to use it for nullable uuid fields instead of NullableString.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nogates nogates requested review from a team as code owners May 29, 2026 10:42
@datadog-prod-us1-3
Copy link
Copy Markdown

datadog-prod-us1-3 Bot commented May 29, 2026

Pipelines

Fix all issues with BitsAI

⚠️ Warnings

🚦 1 Pipeline job failed

Ensure labels | changelog   View in Datadog   GitHub Actions

🛟 This job is unlikely to succeed on retry. Please review your pipeline configuration. Missing required changelog label: 'changelog/*'.

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 1028b09 | Docs | Datadog PR Page | Give us feedback!

@nogates nogates added changelog/Added Added features results into a minor version bump changelog/no-changelog Changes don't appear in changelog and removed changelog/Added Added features results into a minor version bump labels Jun 1, 2026
@nogates nogates merged commit 7670114 into master Jun 1, 2026
29 of 30 checks passed
@nogates nogates deleted the nogates/fix-nullable-uuid-template branch June 1, 2026 08:19
github-actions Bot pushed a commit that referenced this pull request Jun 1, 2026
* Fix nullable UUID type mismatch in Go code generator

Nullable UUID fields (format: uuid, nullable: true) were being mapped to
NullableString, causing getter/setter methods to return *string while
the method signatures expected uuid.UUID — a compile error.

Add a dedicated NullableUUID type to utils.j2 and update formatter.py
to use it for nullable uuid fields instead of NullableString.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* pre-commit fixes

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com> 7670114
github-actions Bot pushed a commit to ConnectionMaster/datadog-api-client-go that referenced this pull request Jun 1, 2026
* Fix nullable UUID type mismatch in Go code generator

Nullable UUID fields (format: uuid, nullable: true) were being mapped to
NullableString, causing getter/setter methods to return *string while
the method signatures expected uuid.UUID — a compile error.

Add a dedicated NullableUUID type to utils.j2 and update formatter.py
to use it for nullable uuid fields instead of NullableString.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* pre-commit fixes

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com> 7670114
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/no-changelog Changes don't appear in changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants