<#7596 feat: emit and parse durations as ISO-8601 ...
# flyte-github
a
#7596 feat: emit and parse durations as ISO-8601 in launch form converter Pull request opened by ursucarina Why are the changes needed? Launch form duration fields are declared in JSON Schema with
format: "duration"
, which per the spec means an ISO-8601 duration string (e.g.
P2DT3H
). The converter instead emitted Go-style strings (
time.Duration.String()
, e.g.
2h30m
) and only parsed bare-seconds or Go-style strings on the way back in. This made the converter's
DURATION
handling inconsistent with the
format: "duration"
schema it produces, and it rejected ISO-8601 input. What changes were proposed in this pull request? This makes the launch form converter (
runs/service/converter/literal_json_converter.go
) speak ISO-8601 for `DURATION`: •
literalToJsonValues
now formats durations as ISO-8601 (
formatISO8601Duration
) instead of
Duration.String()
. •
jsonValueToLiteral
(the
SimpleType_DURATION
case) now parses ISO-8601 first, then falls back to bare seconds and Go-style duration strings for backward compatibility. • Added
isISO8601Duration
/
parseISO8601Duration
/
formatISO8601Duration
helpers. Year and month lengths are fixed (365-day years, 30-day months) so durations round-trip deterministically. How was this patch tested? Unit tests in `runs/service/converter/literal_json_converter_test.go`: • Updated the existing duration literal assertion to expect ISO-8601 (
PT1H30M
). • Added
TestFormatISO8601Duration
,
TestParseISO8601Duration
(valid, invalid, and format↔️parse round-trip cases), and
TestJSONValuesToLiteralsDuration
covering ISO-8601 plus the backward-compatible bare-seconds and Go-style inputs.
go test ./runs/service/converter/
passes. Labels • changed Check all the applicable boxes • I updated the documentation accordingly. • All new and existing tests passed. • All commits are signed-off. • #6583 • feat: emit and parse durations as ISO-8601 in launch form converter 👈 flyteorg/flyte