forgejo/routers/api/v1/repo
Mathieu Fenniak 906e2e7c4a fix: false error logging "Render JSON failed" from workflow dispatch via API (#9675)
When making a `POST` to start a workflow dispatch, and not specifying the option `"return_run_info": true`, the API handler attempts to render a `nil` as a JSON body to a `204 No Content` response.  This results in an error being logged to the console, as this status code does not permit a body.
```
Render JSON failed: http: request method or response status code does not allow body
```

There is no functional impact except for a false error log, as `ctx.JSON` just logs a `Render JSON failed` error if it fails.

I could not find any existing code which allows integration tests to intercept or inspect log output, which would be required for an automated test verifying this is fixed.  If anyone could advise an existing test that performs log interception, or any hints on how such a mechanism would be created, I don't mind adding it... but it may not be warranted for such a tiny bug either.

## 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.
  - [ ] 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

- [ ] I do not want this change to show in the release notes.
- [x] 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/9675
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net>
Co-committed-by: Mathieu Fenniak <mathieu@fenniak.net>
2025-10-14 02:10:46 +02:00
..
action.go fix: false error logging "Render JSON failed" from workflow dispatch via API (#9675) 2025-10-14 02:10:46 +02:00
avatar.go chore(api): update swagger method descripitons (#8728) 2025-07-30 18:08:28 +02:00
blob.go feat: API GET /repos/{owner}/{repo}/git/blobs 2025-06-13 13:52:56 +02:00
branch.go chore: Refactor Is{Reference,Branch}Exist (#8425) 2025-07-06 07:16:43 +02:00
collaborators.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
commits.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
compare.go fix: make API /repos/{owner}/{repo}/compare/{basehead} work with forks (#8326) 2025-06-28 23:28:12 +02:00
download.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
file.go Update Swagger annotations to reflect actual behavior (#9138) 2025-09-15 11:55:49 +02:00
flags.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
fork.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
git_hook.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
git_ref.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
hook.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
hook_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
issue.go feat: show more relevant results for 'dependencies' dropdown (#8003) 2025-06-26 20:06:21 +02:00
issue_attachment.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_comment.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_comment_attachment.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_dependency.go Update Swagger annotations to reflect actual behavior (#9138) 2025-09-15 11:55:49 +02:00
issue_label.go feat: make upload URL compatible with GitHub API (#9285) 2025-09-15 15:53:35 +02:00
issue_pin.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_reaction.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_stopwatch.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_subscription.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_tracked_time.go chore(cleanup): replaces unnecessary calls to formatting functions by non-formatting equivalents (#7994) 2025-05-29 17:34:29 +02:00
key.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
label.go Update Swagger annotations to reflect actual behavior (#9138) 2025-09-15 11:55:49 +02:00
language.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
main_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
migrate.go fix: don't allow credentials in migrate/push mirror URL 2025-08-30 08:07:23 +02:00
milestone.go Update Swagger annotations to reflect actual behavior (#9138) 2025-09-15 11:55:49 +02:00
mirror.go fix: don't allow credentials in migrate/push mirror URL 2025-08-30 08:07:23 +02:00
notes.go chore(cleanup): replaces unnecessary calls to formatting functions by non-formatting equivalents (#7994) 2025-05-29 17:34:29 +02:00
patch.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
pull.go fix: prevent pull requests from being merged multiple times 2025-08-11 12:55:25 +02:00
pull_review.go chore(api): update swagger method descripitons (#8728) 2025-07-30 18:08:28 +02:00
release.go feat: make upload URL compatible with GitHub API (#9285) 2025-09-15 15:53:35 +02:00
release_attachment.go feat: make upload URL compatible with GitHub API (#9285) 2025-09-15 15:53:35 +02:00
release_tags.go feat: make upload URL compatible with GitHub API (#9285) 2025-09-15 15:53:35 +02:00
repo.go Update Swagger annotations to reflect actual behavior (#9138) 2025-09-15 11:55:49 +02:00
repo_test.go feat: Add converting mirror repos to normal to the API (#8932) 2025-09-14 14:25:05 +02:00
star.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
status.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
subscriber.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
sync_fork.go feat: sync forks (#2364) 2025-04-07 07:00:38 +00:00
tag.go Update Swagger annotations to reflect actual behavior (#9138) 2025-09-15 11:55:49 +02:00
tag_test.go fix(api): set default pagination and Link header for repoListTags (#9201) 2025-09-09 02:24:07 +02:00
teams.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
topic.go Update Swagger annotations to reflect actual behavior (#9138) 2025-09-15 11:55:49 +02:00
transfer.go chore(cleanup): replaces unnecessary calls to formatting functions by non-formatting equivalents (#7994) 2025-05-29 17:34:29 +02:00
tree.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
wiki.go git/blob: GetContentBase64 with fewer allocations and no goroutine (#8297) 2025-06-27 11:22:10 +02:00