{"record":{"id":"dce691e367955759","repo":"apache/beam","slug":"unsupported-time-policy","errorCode":null,"errorMessage":"unsupported time policy","messagePattern":"unsupported time policy","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/io/natsio/time_policy.go","lineNumber":48,"sourceCode":"\ntype timestampFn func(time.Time) mtime.Time\n\nfunc processingTime(_ time.Time) mtime.Time {\n\treturn mtime.Now()\n}\n\nfunc publishingTime(t time.Time) mtime.Time {\n\treturn mtime.FromTime(t)\n}\n\nfunc (p timePolicy) TimestampFn() timestampFn {\n\tswitch p {\n\tcase processingTimePolicy:\n\t\treturn processingTime\n\tcase publishingTimePolicy:\n\t\treturn publishingTime\n\tdefault:\n\t\tpanic(\"unsupported time policy\")\n\t}\n}\n","sourceCodeStart":30,"sourceCodeEnd":51,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/natsio/time_policy.go#L30-L51","documentation":"The natsio TimestampFn panics when the configured time policy does not match any known policy (processing-time or publishing-time). The library only supports its two enumerated policies and treats any other value as a programming error. This fires at Setup time, i.e. when the DoFn initializes on a worker.","triggerScenarios":"Constructing a timestampFn (or configuring the reader) with a policy value that is neither processingTimePolicy nor publishingTimePolicy — e.g. a zero-value struct where the policy field was never set, or a hand-written policy string.","commonSituations":"Forgetting to apply a WithTimestampPolicy-style option so the field holds its zero value; refactoring policy constants; building a custom DoFn that reuses TimestampFn with an uninitialized policy.","solutions":["Set an explicit, supported time policy (processing-time or publishing-time) via the package's option/constructor.","Check that the policy field is not left at its zero value before building the pipeline.","Use the package's exported policy constants/constructors rather than raw values."],"exampleFix":"// before\nfn := natsio.NewTimestampFn(\"eventTime\") // unsupported\n// after\nfn := natsio.NewTimestampFn(natsio.PublishingTimePolicy)","handlingStrategy":"validation","validationCode":"if policy != natsio.ProcessingTimePolicy && policy != natsio.PublishingTimePolicy {\n    return errors.New(\"time policy must be processing or publishing time\")\n}","typeGuard":null,"tryCatchPattern":"defer func() {\n    if r := recover(); r != nil {\n        if s, ok := r.(string); ok && s == \"unsupported time policy\" {\n            // handle\n        } else { panic(r) }\n    }\n}()","preventionTips":["Always set the time policy explicitly via the package's constants/constructors.","Never rely on zero values for policy fields.","Add a unit test that constructs the DoFn with each supported policy."],"tags":["go","apache-beam","nats","panic","unsupported-policy"],"backgroundTag":"unsupported-enum-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}