actions: crash if action yaml cannot be parsed #10493

Closed
opened 2025-11-02 09:09:18 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @krombel on GitHub (Mar 23, 2023).

Description

When there is an error with the yaml syntax gitea crashes

Gitea Version

1.19.0

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

2023/03/22 15:07:24 [641b19ac-8] router: completed POST /api/internal/ssh/1/update/8 for 172.19.0.1:0, 200 OK in 2.6ms @ private/key.go:17(private.UpdatePublicKeyInRepo)
Received disconnect from 172.19.0.1 port 49392:11: disconnected by user
Disconnected from user git 172.19.0.1 port 49392
2023/03/22 15:07:25 ...les/cache/context.go:62:GetContextData() [W] [641b19ad] cannot get cache context when getting data: &{context.Background.WithCancel.WithCancel.WithValue(type pprof.labelContextKey, val {"graceful-lifecycle":"with-hammer"}) 0xc005052a00 false}
2023/03/22 15:07:25 ...les/cache/context.go:71:SetContextData() [W] [641b19ad] cannot get cache context when setting data: &{context.Background.WithCancel.WithCancel.WithValue(type pprof.labelContextKey, val {"graceful-lifecycle":"with-hammer"}) 0xc005052a00 false}
2023/03/22 15:07:25 ...les/cache/context.go:62:GetContextData() [W] cannot get cache context when getting data: &{context.Background.WithCancel.WithCancel.WithValue(type pprof.labelContextKey, val {"graceful-lifecycle":"with-hammer"}) 0xc005052a00 false}
2023/03/22 15:07:25 ...les/cache/context.go:71:SetContextData() [W] cannot get cache context when setting data: &{context.Background.WithCancel.WithCancel.WithValue(type pprof.labelContextKey, val {"graceful-lifecycle":"with-hammer"}) 0xc005052a00 false}
2023/03/22 15:07:25 ...les/cache/context.go:62:GetContextData() [W] cannot get cache context when getting data: *db.Context.WithValue(type struct {}, val NotifyPushCommits)
2023/03/22 15:07:25 ...les/cache/context.go:71:SetContextData() [W] cannot get cache context when setting data: *db.Context.WithValue(type struct {}, val NotifyPushCommits)
2023/03/22 15:07:25 ...les/cache/context.go:62:GetContextData() [W] cannot get cache context when getting data: *db.Context.WithValue(type struct {}, val NotifyPushCommits)
2023/03/22 15:07:25 ...les/cache/context.go:71:SetContextData() [W] cannot get cache context when setting data: *db.Context.WithValue(type struct {}, val NotifyPushCommits)
time="2023-03-22T15:07:25Z" level=fatal msg="yaml: unmarshal errors:\n  line 210: cannot unmarshal !!str `${{ fro...` into []interface {}"
Received signal 15; terminating.

Git Version

No response

Operating System

No response

How are you running Gitea?

docker

Database

None

Originally created by @krombel on GitHub (Mar 23, 2023). ### Description When there is an error with the yaml syntax gitea crashes ### Gitea Version 1.19.0 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots ``` 2023/03/22 15:07:24 [641b19ac-8] router: completed POST /api/internal/ssh/1/update/8 for 172.19.0.1:0, 200 OK in 2.6ms @ private/key.go:17(private.UpdatePublicKeyInRepo) Received disconnect from 172.19.0.1 port 49392:11: disconnected by user Disconnected from user git 172.19.0.1 port 49392 2023/03/22 15:07:25 ...les/cache/context.go:62:GetContextData() [W] [641b19ad] cannot get cache context when getting data: &{context.Background.WithCancel.WithCancel.WithValue(type pprof.labelContextKey, val {"graceful-lifecycle":"with-hammer"}) 0xc005052a00 false} 2023/03/22 15:07:25 ...les/cache/context.go:71:SetContextData() [W] [641b19ad] cannot get cache context when setting data: &{context.Background.WithCancel.WithCancel.WithValue(type pprof.labelContextKey, val {"graceful-lifecycle":"with-hammer"}) 0xc005052a00 false} 2023/03/22 15:07:25 ...les/cache/context.go:62:GetContextData() [W] cannot get cache context when getting data: &{context.Background.WithCancel.WithCancel.WithValue(type pprof.labelContextKey, val {"graceful-lifecycle":"with-hammer"}) 0xc005052a00 false} 2023/03/22 15:07:25 ...les/cache/context.go:71:SetContextData() [W] cannot get cache context when setting data: &{context.Background.WithCancel.WithCancel.WithValue(type pprof.labelContextKey, val {"graceful-lifecycle":"with-hammer"}) 0xc005052a00 false} 2023/03/22 15:07:25 ...les/cache/context.go:62:GetContextData() [W] cannot get cache context when getting data: *db.Context.WithValue(type struct {}, val NotifyPushCommits) 2023/03/22 15:07:25 ...les/cache/context.go:71:SetContextData() [W] cannot get cache context when setting data: *db.Context.WithValue(type struct {}, val NotifyPushCommits) 2023/03/22 15:07:25 ...les/cache/context.go:62:GetContextData() [W] cannot get cache context when getting data: *db.Context.WithValue(type struct {}, val NotifyPushCommits) 2023/03/22 15:07:25 ...les/cache/context.go:71:SetContextData() [W] cannot get cache context when setting data: *db.Context.WithValue(type struct {}, val NotifyPushCommits) time="2023-03-22T15:07:25Z" level=fatal msg="yaml: unmarshal errors:\n line 210: cannot unmarshal !!str `${{ fro...` into []interface {}" Received signal 15; terminating. ``` ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? docker ### Database None
GiteaMirror added the topic/gitea-actionstype/bug labels 2025-11-02 09:09:18 -06:00
Author
Owner

@lunny commented on GitHub (Mar 23, 2023):

Could you provide the yaml file here?

@lunny commented on GitHub (Mar 23, 2023): Could you provide the yaml file here?
Author
Owner

@ghnp5 commented on GitHub (Mar 25, 2023):

Yeah, I was going to report exactly this!

@lunny - I got this:

time="2023-03-25T15:22:18Z" level=fatal msg="yaml: unmarshal errors:\n line 61: cannot unmarshal !!str ${{ fro... into []interface {}"
Received signal 15; terminating.

I was wondering why the Action didn't trigger. No logs anywhere, but then I found it in the Gitea docker logs.

In my case, I'm doing this (minimal example):

jobs:
  c_set_matrix:
    name: Set Matrix
    runs-on: ubuntu-latest
    outputs:
      matrix: ${{ steps.set_matrix.outputs.domains }}
    steps:
      - name: Set Matrix
        id: set_matrix
        run: |
          echo "domains=[...]" >> $GITHUB_OUTPUT

  d_deploy:
    name: Deploy
    runs-on: ubuntu-latest
    needs: c_set_matrix
    strategy:
      matrix:
        stage:
          - server1
          - server2
          - server3
          - server4
        domain: ${{ fromJSON(needs.c_set_matrix.outputs.matrix) }}
    steps:
      - ...

So, two issues I see here:

  1. Gitea is completely crashing if there is a syntax error in a workflow

  2. fromJSON() should work (but could well be my fault, as I never worked with GitHub Actions before), as per https://docs.github.com/en/actions/learn-github-actions/expressions#example-returning-a-json-object

@ghnp5 commented on GitHub (Mar 25, 2023): Yeah, I was going to report exactly this! @lunny - I got this: > time="2023-03-25T15:22:18Z" level=fatal msg="yaml: unmarshal errors:\n line 61: cannot unmarshal !!str `${{ fro...` into []interface {}" > Received signal 15; terminating. I was wondering why the Action didn't trigger. No logs anywhere, but then I found it in the Gitea docker logs. In my case, I'm doing this (minimal example): ``` jobs: c_set_matrix: name: Set Matrix runs-on: ubuntu-latest outputs: matrix: ${{ steps.set_matrix.outputs.domains }} steps: - name: Set Matrix id: set_matrix run: | echo "domains=[...]" >> $GITHUB_OUTPUT d_deploy: name: Deploy runs-on: ubuntu-latest needs: c_set_matrix strategy: matrix: stage: - server1 - server2 - server3 - server4 domain: ${{ fromJSON(needs.c_set_matrix.outputs.matrix) }} steps: - ... ``` So, two issues I see here: 1) Gitea is completely crashing if there is a syntax error in a workflow 2) `fromJSON()` should work (but could well be my fault, as I never worked with GitHub Actions before), as per https://docs.github.com/en/actions/learn-github-actions/expressions#example-returning-a-json-object
Author
Owner

@lunny commented on GitHub (Mar 26, 2023):

I cannot reproduce the crash in my local machine with 1.19 or main branch with your above content as a workflow file.

@lunny commented on GitHub (Mar 26, 2023): I cannot reproduce the crash in my local machine with 1.19 or main branch with your above content as a workflow file.
Author
Owner

@wxiaoguang commented on GitHub (Mar 26, 2023):

I guess the author means that the act runner crashes.

The log is: time="2023-03-25T15:22:18Z" level=fatal msg="yaml: unmarshal errors:\n line 61: cannot unmarshal !!str ${{ fro... into []interface {}" , it comes from the runner?

Hmm ... it seems that I misunderstood. Author meant that "Gitea is completely crashing"

@wxiaoguang commented on GitHub (Mar 26, 2023): <details> I guess the author means that the act runner crashes. The log is: `time="2023-03-25T15:22:18Z" level=fatal msg="yaml: unmarshal errors:\n line 61: cannot unmarshal !!str ${{ fro... into []interface {}"` , it comes from the runner? </details> Hmm ... it seems that I misunderstood. Author meant that "Gitea is completely crashing"
Author
Owner

@wxiaoguang commented on GitHub (Mar 26, 2023):

OK, I know the problem now.

The problem is that a lot of code in act package uses log.Fatal

You can even reproduce the crash with a very simple YAML.

To fix the problem .... replace all log.Fatal with return err

func TestActCrash(t *testing.T) {
	workflow, err := model.ReadWorkflow(bytes.NewReader([]byte(`
name: checks
on:
  - asfd:
    - a
`)))
	assert.NoError(t, err)
	workflow.On()
	t.Log("Succeeded")
}

Then

=== RUN   TestActCrash
time="2023-03-26T23:02:28+08:00" level=fatal msg="yaml: unmarshal errors:\n  line 4: cannot unmarshal !!map into string"
@wxiaoguang commented on GitHub (Mar 26, 2023): OK, I know the problem now. The problem is that a lot of code in `act` package uses `log.Fatal` You can even reproduce the crash with a very simple YAML. To fix the problem .... replace all `log.Fatal` with `return err` ```go func TestActCrash(t *testing.T) { workflow, err := model.ReadWorkflow(bytes.NewReader([]byte(` name: checks on: - asfd: - a `))) assert.NoError(t, err) workflow.On() t.Log("Succeeded") } ``` Then ``` === RUN TestActCrash time="2023-03-26T23:02:28+08:00" level=fatal msg="yaml: unmarshal errors:\n line 4: cannot unmarshal !!map into string" ```
Author
Owner

@ghnp5 commented on GitHub (Mar 26, 2023):

Hey

Yeah, I meant the Gitea docker container, not the "act_runner" daemon.

Great if you were able to find the reason for the crash!

Thanks!

@ghnp5 commented on GitHub (Mar 26, 2023): Hey Yeah, I meant the Gitea docker container, not the "act_runner" daemon. Great if you were able to find the reason for the crash! Thanks!
Author
Owner

@wolfogre commented on GitHub (Mar 28, 2023):

I am tring to fix it on https://github.com/nektos/act/pull/1705

@wolfogre commented on GitHub (Mar 28, 2023): I am tring to fix it on https://github.com/nektos/act/pull/1705
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10493