{"record":{"id":"3c091af8d60da9e1","repo":"weaviate/weaviate","slug":"date-as-string-expected-got-t","errorCode":null,"errorMessage":"date as string expected, got %T","messagePattern":"date as string expected, got %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"usecases/traverser/explorer.go","lineNumber":973,"sourceCode":"\t}\n\n\tvar expirationTime time.Time\n\n\tswitch class.ObjectTTLConfig.DeleteOn {\n\tcase filters.InternalPropCreationTimeUnix:\n\t\texpirationTime = time.UnixMilli(input.Created)\n\n\tcase filters.InternalPropLastUpdateTimeUnix:\n\t\texpirationTime = time.UnixMilli(input.Updated)\n\tdefault:\n\t\tdateTime, exists := input.Schema.(map[string]interface{})[class.ObjectTTLConfig.DeleteOn]\n\t\tif !exists {\n\t\t\t// if object has no TTL date set, we keep it\n\t\t\treturn true, nil\n\t\t}\n\t\tdeleteOnTimeStr, ok := dateTime.(string)\n\t\tif !ok {\n\t\t\treturn false, fmt.Errorf(\"date as string expected, got %T\", dateTime)\n\t\t}\n\t\tvar err error\n\t\texpirationTime, err = time.Parse(time.RFC3339, deleteOnTimeStr)\n\t\tif err != nil {\n\t\t\treturn false, fmt.Errorf(\"parse date: %w\", err)\n\t\t}\n\t}\n\texpirationThreshold := expirationTime.Add(time.Second * time.Duration(class.ObjectTTLConfig.DefaultTTL))\n\treturn expirationThreshold.After(searchStartTime), nil\n}\n\nfunc ExtractDistanceFromParams(params dto.GetParams) (distance float64, withDistance bool) {\n\tif params.NearVector != nil {\n\t\tdistance = params.NearVector.Distance\n\t\twithDistance = params.NearVector.WithDistance\n\t\treturn distance, withDistance\n\t}\n","sourceCodeStart":955,"sourceCodeEnd":991,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/usecases/traverser/explorer.go#L955-L991","documentation":"When a class has ObjectTTL configured, keepObjectsWithTTL reads the TTL property value from each result and expects it to be a string (RFC3339 date). If the stored property value is any other Go type, the object cannot be evaluated for expiration and this type-mismatch error is thrown for the whole result set.","triggerScenarios":"The TTL/expiration property contains a non-string value — e.g. the property was created with dataType date and stored as text2vec/time differently, or the configured ttlProperty points at a property whose value is an int/number or a non-date string.","commonSituations":"Pointing ObjectTTLConfig at the wrong property (one holding a number or unrelated text); importing dates as arbitrary strings; schema type changed from string to date (or vice versa) after objects existed.","solutions":["Ensure the property named in ObjectTTLConfig contains RFC3339 date strings (e.g. \"2026-01-01T00:00:00Z\").","Verify the ttlProperty name is correct — it may be pointing at a numeric or unrelated property.","Fix or re-import objects whose TTL property holds non-date values.","Check schema history for a type change on the TTL property and migrate the data if needed."],"exampleFix":"// before — TTL property holds a unix timestamp number\n{\"deleteOn\": 1735689600}\n\n// after — RFC3339 string\n{\"deleteOn\": \"2026-01-01T00:00:00Z\"}","handlingStrategy":"type-guard","validationCode":"v, ok := obj.Properties[\"deleteOn\"]\nif !ok {\n    return errors.New(\"TTL property missing\")\n}\ns, ok := v.(string)\nif !ok {\n    return fmt.Errorf(\"TTL property must be a string, got %T\", v)\n}\nif _, err := time.Parse(time.RFC3339, s); err != nil {\n    return fmt.Errorf(\"TTL property not RFC3339: %w\", err)\n}","typeGuard":"func isRFC3339String(v interface{}) (string, bool) {\n    s, ok := v.(string)\n    if !ok {\n        return \"\", false\n    }\n    if _, err := time.Parse(time.RFC3339, s); err != nil {\n        return \"\", false\n    }\n    return s, true\n}","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"date as string expected\") {\n    // fix data: TTL property holds a non-string value\n}","preventionTips":["Point ObjectTTLConfig.ttlProperty at a property that is genuinely a date string.","Validate TTL values client-side before every import.","Never change the TTL property's data type without migrating existing objects."],"tags":["ttl","type-mismatch","data-quality"],"backgroundTag":"unexpected-property-type","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}