fix: permit larger single-line output sizes to be parsed from FORGEJO_OUTPUT file #1359

Merged
mfenniak merged 1 commit from mfenniak/forgejo-runner:parse-larger-outputs into main 2026-02-08 21:23:33 +00:00
Owner

Forgejo is supposed to have a 1MB max output size (codeberg.org/forgejo/forgejo@f24a97f719/routers/api/actions/runner/runner.go (L209-L213)), but the parsing of FORGEJO_OUTPUT didn't permit more than 64kB per-line (eg. "output=value" must be < 64kB).

Fixes #1353.

  • bug fixes
    • PR: fix: permit larger single-line output sizes to be parsed from FORGEJO_OUTPUT file
Forgejo is supposed to have a 1MB max output size (https://codeberg.org/forgejo/forgejo/src/commit/f24a97f7198f6d2f36bd8a133d463f33011e8fc9/routers/api/actions/runner/runner.go#L209-L213), but the parsing of `FORGEJO_OUTPUT` didn't permit more than 64kB per-line (eg. "output=value" must be < 64kB). Fixes #1353. <!--start release-notes-assistant--> <!--URL:https://code.forgejo.org/forgejo/runner--> - bug fixes - [PR](https://code.forgejo.org/forgejo/runner/pulls/1359): <!--number 1359 --><!--line 0 --><!--description Zml4OiBwZXJtaXQgbGFyZ2VyIHNpbmdsZS1saW5lIG91dHB1dCBzaXplcyB0byBiZSBwYXJzZWQgZnJvbSBGT1JHRUpPX09VVFBVVCBmaWxl-->fix: permit larger single-line output sizes to be parsed from FORGEJO_OUTPUT file<!--description--> <!--end release-notes-assistant-->
mfenniak force-pushed parse-larger-outputs from 384db1a504
Some checks failed
issue-labels / release-notes (pull_request_target) Successful in 4s
checks / Build Forgejo Runner (pull_request) Failing after 35s
checks / validate pre-commit-hooks file (pull_request) Successful in 36s
checks / Build unsupported platforms (pull_request) Has been skipped
checks / runner exec tests (pull_request) Has been skipped
checks / integration tests (docker-stable) (pull_request) Has been skipped
checks / integration tests (docker-latest) (pull_request) Has been skipped
checks / validate mocks (pull_request) Successful in 1m4s
to 084ef24b14
All checks were successful
cascade / end-to-end (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
cascade / forgejo (pull_request_target) Has been skipped
issue-labels / release-notes (pull_request_target) Successful in 5s
checks / Build Forgejo Runner (pull_request) Successful in 34s
checks / validate pre-commit-hooks file (pull_request) Successful in 34s
checks / validate mocks (pull_request) Successful in 36s
checks / runner exec tests (pull_request) Successful in 42s
checks / Build unsupported platforms (pull_request) Successful in 56s
checks / integration tests (docker-latest) (pull_request) Successful in 8m47s
checks / integration tests (docker-stable) (pull_request) Successful in 12m4s
2026-02-08 04:14:09 +00:00
Compare
@ -25,6 +25,8 @@ func parseEnvFile(e Container, srcPath string, env *map[string]string) common.Ex
return err
}
s := bufio.NewScanner(reader)
// Action outputs can be up to 1MB, plus the "key=" prefix and "\n" suffix, so allow 256b + 1MB max buffer size
Member

Would be good to link to the place that stipulates that outputs can be up to 1 MB. Facilitates code archaeology.

What about better distinguishing the output size from the buffer size? Example: "The maximum allowed output size is 1 MiB. The buffer must be 256 bytes bigger to account for the prefix (maximum of 255 bytes) and the \n suffix."

Edit: Does the maximum length of the prefix include = or not? If it does not, the buffer needs to be 1 byte bigger.

Would be good to link to the place that stipulates that outputs can be up to 1 MB. Facilitates code archaeology. What about better distinguishing the output size from the buffer size? Example: "The maximum allowed output size is 1 MiB. The buffer must be 256 bytes bigger to account for the prefix (maximum of 255 bytes) and the `\n` suffix." Edit: Does the maximum length of the prefix include `=` or not? If it does not, the buffer needs to be 1 byte bigger.
Author
Owner

I've updated the related comment, and added a test at both the key & value extremes to ensure the buffer is sized appropriately.

I've updated the related comment, and added a test at both the key & value extremes to ensure the buffer is sized appropriately.
aahlenst marked this conversation as resolved
@ -26,2 +26,4 @@
}
s := bufio.NewScanner(reader)
// Action outputs can be up to 1MB, plus the "key=" prefix and "\n" suffix, so allow 256b + 1MB max buffer size
s.Buffer(make([]byte, 0, 1024), 256+(1024*1024))
Member

Is there a way to emit a warning when the output is bigger, for example, by checking Err()?

Is there a way to emit a warning when the output is bigger, for example, by checking `Err()`?
Author
Owner

Ah, this is a great idea. But I'm tempted to (and have updated the PR) to make this an error rather than a warning. What do you think? 🤔 My thought is that you've got a subtle data loss issue in an edge case -- an error that stops the workflow is better than a warning that could be missed.

Ah, this is a great idea. But I'm tempted to (and have updated the PR) to make this an error rather than a warning. What do you think? 🤔 My thought is that you've got a subtle data loss issue in an edge case -- an error that stops the workflow is better than a warning that could be missed.
@ -0,0 +46,4 @@
name: "1MB value",
rawContents: fmt.Sprintf("abc=%s\n", data1Mb.String()),
mapContents: map[string]string{"abc": data1Mb.String()},
},
Member

If I understand codeberg.org/forgejo/forgejo@f24a97f719/routers/api/actions/runner/runner.go (L205-L208) correctly, the maximum key length is 255 characters. What about adding a test with a 255 characters long key?

If I understand https://codeberg.org/forgejo/forgejo/src/commit/f24a97f7198f6d2f36bd8a133d463f33011e8fc9/routers/api/actions/runner/runner.go#L205-L208 correctly, the maximum key length is 255 characters. What about adding a test with a 255 characters long key?
Author
Owner

Sounds good.

Sounds good.
aahlenst marked this conversation as resolved
mfenniak force-pushed parse-larger-outputs from 084ef24b14
All checks were successful
cascade / end-to-end (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
cascade / forgejo (pull_request_target) Has been skipped
issue-labels / release-notes (pull_request_target) Successful in 5s
checks / Build Forgejo Runner (pull_request) Successful in 34s
checks / validate pre-commit-hooks file (pull_request) Successful in 34s
checks / validate mocks (pull_request) Successful in 36s
checks / runner exec tests (pull_request) Successful in 42s
checks / Build unsupported platforms (pull_request) Successful in 56s
checks / integration tests (docker-latest) (pull_request) Successful in 8m47s
checks / integration tests (docker-stable) (pull_request) Successful in 12m4s
to 778017036e
All checks were successful
issue-labels / release-notes (pull_request_target) Successful in 8s
checks / validate pre-commit-hooks file (pull_request) Successful in 32s
checks / Build Forgejo Runner (pull_request) Successful in 37s
checks / validate mocks (pull_request) Successful in 39s
checks / Build unsupported platforms (pull_request) Successful in 20s
checks / runner exec tests (pull_request) Successful in 32s
checks / integration tests (docker-latest) (pull_request) Successful in 8m58s
checks / integration tests (docker-stable) (pull_request) Successful in 11m11s
cascade / debug (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Successful in 5s
cascade / forgejo (pull_request_target) Successful in 1m2s
2026-02-08 20:12:02 +00:00
Compare
aahlenst approved these changes 2026-02-08 21:14:28 +00:00
Member

Looks great now, thanks a lot!

Looks great now, thanks a lot!
mfenniak deleted branch parse-larger-outputs 2026-02-08 21:23:34 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
forgejo/runner!1359
No description provided.