uranusjr commented on code in PR #75737:
URL: https://github.com/apache/airflow/pull/75737#discussion_r4507980092
##########
go-sdk/pkg/execution/genmodels/gen/main.go:
##########
@@ -354,9 +365,210 @@ func identUseCounts(file *ast.File) map[string]int {
return counts
}
+// timeTypeName is the hand-written UTC-decoding type in the genmodels package.
+const timeTypeName = "Time"
+
+func (p schemaProp) isDateTime() bool { return p.Format == "date-time" }
+
+func (p schemaProp) isNull() bool { return p.Type == "null" }
+
+// hasDateTime reports whether p carries a date-time anywhere, so a shape
+// findNullableDateTimes does not recognise fails generation instead of being
skipped.
+func (p schemaProp) hasDateTime() bool {
+ if p.isDateTime() || (p.Items != nil && p.Items.hasDateTime()) {
+ return true
+ }
+ for _, branch := range p.AnyOf {
+ if branch.hasDateTime() {
+ return true
+ }
+ }
+ return false
+}
+
+// nonNullBranch returns X for an anyOf [X, null] prop.
+func (p schemaProp) nonNullBranch() (schemaProp, bool) {
+ if len(p.AnyOf) != 2 {
+ return schemaProp{}, false
+ }
+ value, null := p.AnyOf[0], p.AnyOf[1]
+ if value.isNull() {
+ value, null = null, value
+ }
+ return value, null.isNull()
+}
+
+// findNullableDateTimes returns structName -> wire tag for every
+// anyOf [date-time, null] prop. go-jsonschema renders those as interface{},
+// which the AST cannot tell apart from other nullable scalars; every other
+// date-time it renders as time.Time, which retypeDateTimes swaps by type
alone.
+func findNullableDateTimes(
+ doc *schemaDoc,
+ structByKey map[string]string,
+) (map[string]map[string]bool, error) {
+ set := map[string]map[string]bool{}
+ for defName, def := range doc.Defs {
+ structName, ok := structByKey[strings.ToUpper(defName)]
+ if !ok {
+ continue
+ }
+ for propName, prop := range def.Properties {
+ if !prop.hasDateTime() {
+ continue
+ }
Review Comment:
A `$def` with a date-time but no matching generated struct is skipped
silently; its nullable date-time would stay `interface{}` and decode in local
time. Fail instead.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]