feat: increase default limit of dispatch inputs to 100 (#10563)
Some checks are pending
/ release (push) Waiting to run
testing-integration / test-unit (push) Waiting to run
testing-integration / test-sqlite (push) Waiting to run
testing-integration / test-mariadb (v10.6) (push) Waiting to run
testing-integration / test-mariadb (v11.8) (push) Waiting to run
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-e2e (push) Blocked by required conditions
testing / test-remote-cacher (redis) (push) Blocked by required conditions
testing / test-remote-cacher (valkey) (push) Blocked by required conditions
testing / test-remote-cacher (garnet) (push) Blocked by required conditions
testing / test-remote-cacher (redict) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions

Raise the default value for LimitDispatchInputs from 10 to 100.

100 should be plenty while offering some protection against excessively large inputs. Note that the limit only applies to the number of submitted inputs, not the total number of inputs defined in a workflow.

See https://codeberg.org/forgejo/forgejo/pulls/10368 for background and motivation.

The change also prevents the dispatch menu in the UI from becoming too large.

Before:

![dispatch-before](/attachments/b335c5b8-ad1a-44fc-bbd2-99c975c2a5e5)

Afterwards (scrollbars are invisible, unfortunately):

![dispatch-after](/attachments/9934e92c-ce0d-41e5-8e57-fb453cb2736e)

## Checklist

The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org).

### Tests

- I added test coverage for Go changes...
  - [ ] in their respective `*_test.go` for unit tests.
  - [x] in the `tests/integration` directory if it involves interactions with a live Forgejo server.
- I added test coverage for JavaScript changes...
  - [ ] in `web_src/js/*.test.js` if it can be unit tested.
  - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)).

### Documentation

- [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change.
- [x] I did not document these changes and I do not expect someone else to do it.

### Release notes

- [x] I do not want this change to show in the release notes.
- [ ] I want the title to show in the release notes with a link to this pull request.
- [ ] I want the content of the `release-notes/<pull request number>.md` to be be used for the release notes instead of the title.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10563
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org>
Co-authored-by: Andreas Ahlenstorf <andreas@ahlenstorf.ch>
Co-committed-by: Andreas Ahlenstorf <andreas@ahlenstorf.ch>
This commit is contained in:
Andreas Ahlenstorf 2025-12-23 17:49:47 +01:00 committed by Mathieu Fenniak
parent 973ff28f44
commit 57a40f4bcd
5 changed files with 90 additions and 4 deletions

View file

@ -2776,8 +2776,8 @@ LEVEL = Info
;ABANDONED_JOB_TIMEOUT = 24h
;; Strings committers can place inside a commit message or PR title to skip executing the corresponding actions workflow
;SKIP_WORKFLOW_STRINGS = [skip ci],[ci skip],[no ci],[skip actions],[actions skip]
;; Limit on inputs for manual / workflow_dispatch triggers, default is 10
;LIMIT_DISPATCH_INPUTS = 10
;; Limit on inputs for manual / workflow_dispatch triggers, default is 100
;LIMIT_DISPATCH_INPUTS = 100
;; Support queuing workflow jobs, by setting `concurrency.group` & `concurrency.cancel-in-progress: false`, can increase
;; server and database workload due to more complex database queries and more frequent server task querying; this
;; feature can be disabled to reduce performance impact

View file

@ -29,7 +29,7 @@ var (
Enabled: true,
DefaultActionsURL: defaultActionsURLForgejo,
SkipWorkflowStrings: []string{"[skip ci]", "[ci skip]", "[no ci]", "[skip actions]", "[actions skip]"},
LimitDispatchInputs: 10,
LimitDispatchInputs: 100,
ConcurrencyGroupQueueEnabled: true,
}
)

View file

@ -113,7 +113,7 @@ func (entry *Workflow) Dispatch(ctx context.Context, inputGetter InputValueGette
}
if int64(len(inputs)) > setting.Actions.LimitDispatchInputs {
return nil, nil, errors.New("to many inputs")
return nil, nil, errors.New("too many inputs")
}
jobNames := util.KeysOfMap(wf.Jobs)

View file

@ -875,6 +875,88 @@ func TestActionsWorkflowDispatch(t *testing.T) {
})
}
func TestActionsWorkflowDispatchRejectsInputsThatExceedLimit(t *testing.T) {
workflow := `
name: test
on:
workflow_dispatch:
inputs:
boolean:
description: 'Boolean'
type: boolean
number:
description: 'Number'
default: '100'
type: number
string:
description: 'String'
type: string
jobs:
test:
runs-on: ubuntu-latest
steps:
- run: echo "OK"
`
defer test.MockVariableValue(&setting.Actions.LimitDispatchInputs, 2)()
testCases := []struct {
name string
inputs map[string]string
expectedError string
}{
{
name: "below-limit",
inputs: map[string]string{"boolean": "true", "number": "10"},
},
{
name: "beyond-limit",
inputs: map[string]string{"boolean": "true", "number": "10", "string": "my input"},
expectedError: "too many inputs",
},
}
onApplicationRun(t, func(t *testing.T, u *url.URL) {
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
repo, sha, f := tests.CreateDeclarativeRepo(t, user2, "repo-workflow-dispatch",
[]unit_model.Type{unit_model.TypeActions}, nil,
[]*files_service.ChangeRepoFile{
{
Operation: "create",
TreePath: ".forgejo/workflows/dispatch.yaml",
ContentReader: strings.NewReader(workflow),
},
},
)
defer f()
gitRepo, err := gitrepo.OpenRepository(db.DefaultContext, repo)
require.NoError(t, err)
defer gitRepo.Close()
workflow, err := actions_service.GetWorkflowFromCommit(gitRepo, "main", "dispatch.yaml")
require.NoError(t, err)
assert.Equal(t, "refs/heads/main", workflow.Ref)
assert.Equal(t, sha, workflow.Commit.ID.String())
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
inputGetter := func(key string) string {
return testCase.inputs[key]
}
_, _, err = workflow.Dispatch(db.DefaultContext, inputGetter, repo, user2)
if testCase.expectedError == "" {
require.NoError(t, err)
} else {
assert.EqualError(t, err, testCase.expectedError)
}
})
}
})
}
func TestActionsWorkflowDispatchDynamicMatrix(t *testing.T) {
onApplicationRun(t, func(t *testing.T, u *url.URL) {
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})

View file

@ -88,6 +88,10 @@
#workflow_dispatch_dropdown > button {
white-space: nowrap;
}
#workflow_dispatch_dropdown .menu {
max-height: 500px;
overflow-x: auto;
}
@media (max-width: 640px) or (767.98px < width < 854px) {
#workflow_dispatch_dropdown .menu {
left: auto;