feat: Version Jira transition read-only planner reports#630
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements schema versioning for Jira transition plan reports by adding a schema_version field and updating the documentation to clarify that these reports are read-only planning evidence. Feedback suggests improving the consistency of JSON output by ensuring reports are emitted even during error conditions and that the schema enforcement function populates all canonical fields like Command and ReadOnly.
| fmt.Fprintf(stderr, "%v\n", err) | ||
| return 2 | ||
| } | ||
| gira.EnsureJiraTransitionPlanReportSchema(&report) |
There was a problem hiding this comment.
The runJiraTransition function should follow the standard pattern used in other commands (like runSetupGlobal or runRepoRegister) to emit a JSON report even when an error occurs. This ensures that automated tools using the --json flag receive a machine-readable response for all outcomes, which is critical for the adapter contract described in the documentation.
if *jsonOutput {
gira.EnsureJiraTransitionPlanReportSchema(&report)
output, _ := json.MarshalIndent(report, "", " ")
fmt.Fprintf(stdout, "%s\n", output)
}
fmt.Fprintf(stderr, "%v\n", err)
return 2
}
gira.EnsureJiraTransitionPlanReportSchema(&report)| func EnsureJiraTransitionPlanReportSchema(report *JiraTransitionPlanReport) { | ||
| if report.SchemaVersion == "" { | ||
| report.SchemaVersion = JiraTransitionPlanReportSchemaVersion | ||
| } | ||
| } |
There was a problem hiding this comment.
To ensure consistent JSON output for automated tools, EnsureJiraTransitionPlanReportSchema should also populate the Command, DryRun, and ReadOnly fields when initializing a report from an empty state (e.g., in error scenarios). Since this specific report type is defined as a read-only planner report, these fields should always be set to their canonical values.
func EnsureJiraTransitionPlanReportSchema(report *JiraTransitionPlanReport) {
if report.SchemaVersion == "" {
report.SchemaVersion = JiraTransitionPlanReportSchemaVersion
report.Command = "jira transition"
report.DryRun = true
report.ReadOnly = true
}
}
Closes #629