Skip to content

Report structurally invalid workflows to users (#37115)#37116

Open
bircni wants to merge 3 commits intogo-gitea:mainfrom
bircni:fix/invalid_workflow
Open

Report structurally invalid workflows to users (#37115)#37116
bircni wants to merge 3 commits intogo-gitea:mainfrom
bircni:fix/invalid_workflow

Conversation

@bircni
Copy link
Copy Markdown
Member

@bircni bircni commented Apr 5, 2026

model.ReadWorkflow succeeds for YAML that is syntactically valid but fails deeper parsing in jobparser.Parse (e.g. blank lines inside run: | blocks cause a SetJob round-trip error). Add ValidateWorkflowContent which runs the full jobparser.Parse to catch these cases, and use it in the file view, the actions workflow list, and the workflow detection loop so users see the error instead of silently getting a 500 or a dropped workflow.

Fixes #37115

`model.ReadWorkflow` succeeds for YAML that is syntactically valid but
fails deeper parsing in `jobparser.Parse` (e.g. blank lines inside
`run: |` blocks cause a SetJob round-trip error). Add
`ValidateWorkflowContent` which runs the full `jobparser.Parse` to catch
these cases, and use it in the file view, the actions workflow list, and
the workflow detection loop so users see the error instead of silently
getting a 500 or a dropped workflow.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 5, 2026
@bircni bircni marked this pull request as draft April 5, 2026 20:18
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Apr 5, 2026
@bircni bircni marked this pull request as ready for review April 6, 2026 10:23
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Apr 6, 2026
events, err := GetEventsFromContent(content)
if err == nil {
err = ValidateWorkflowContent(content)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? GetEventsFromContent already does something.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/need 1 This PR needs approval from one additional maintainer to be merged. modifies/go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some invalid workflow are not reported as invalid

4 participants