Skip to content

fix(repository-webhook): preserve write-only config.secret - #159

Open
trent-hord wants to merge 1 commit into
svalabs:mainfrom
trent-hord:fix/webhook-config-secret
Open

fix(repository-webhook): preserve write-only config.secret#159
trent-hord wants to merge 1 commit into
svalabs:mainfrom
trent-hord:fix/webhook-config-secret

Conversation

@trent-hord

@trent-hord trent-hord commented Jun 24, 2026

Copy link
Copy Markdown

The webhook secret is supplied inside the config map but Forgejo, like Gitea, treats it as write-only: it is accepted on create/update but never returned by the API. The provider previously rebuilt config wholesale from the API response in from(), dropping the secret key. The planned config therefore differed from the applied config, failing Terraform's post-apply consistency check with "Provider produced inconsistent result after apply ... inconsistent values for sensitive attribute".

Mirror the existing write-only handling (authorization_header, branch_filter) by carrying known write-only config keys over from the prior plan/state value when mapping the API response into state.

Fixes #158

This PR was written in part with the assistance of generative AI

@trent-hord
trent-hord requested a review from acch as a code owner June 24, 2026 04:23
@acch acch added bug Something isn't working go Pull requests that update Go code labels Jul 9, 2026
@acch

acch commented Jul 11, 2026

Copy link
Copy Markdown
Member

Hi @trent-hord, thank you very much for your valuable contribution! This is a good catch indeed - thanks for identifying the root cause and for providing a fix!

The code looks solid, I'm happy to merge it. I do, however, have one concern: feel free to use any tools you like for creating/generating the code - but as the author, you are responsible for understanding every change. Please list yourself (name & email) as the commit author, not your AI tooling.

commit f966b2018932967b8d7a752cdca9f4cd0c1ea1af (HEAD -> fix/webhook-config-secret)
Author: Claude <noreply@anthropic.com>
Date:   Wed Jun 24 04:10:06 2026 +0000

(thanks for disclosing the tools in the description!)

@acch acch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please list yourself (name & email) as the commit author, not your AI tooling.

@acch

acch commented Jul 11, 2026

Copy link
Copy Markdown
Member

FYI: I've added some AI Guidance to the contributing docs...
Note that this is heavily inspired by the Kubernetes AI policy.

@trent-hord
trent-hord marked this pull request as draft July 19, 2026 01:45
@acch

acch commented Aug 4, 2026

Copy link
Copy Markdown
Member

@trent-hord I'm happy to merge this, once you list yourself (name & email) as the commit author...

The webhook `secret` is supplied inside the `config` map but Forgejo,
like Gitea, treats it as write-only: it is accepted on create/update
but never returned by the API. The provider previously rebuilt `config`
wholesale from the API response in `from()`, dropping the `secret` key.
The planned `config` therefore differed from the applied `config`,
failing Terraform's post-apply consistency check with "Provider produced
inconsistent result after apply ... inconsistent values for sensitive
attribute".

Mirror the existing write-only handling (`authorization_header`,
`branch_filter`) by carrying known write-only config keys over from the
prior plan/state value when mapping the API response into state.
@trent-hord
trent-hord force-pushed the fix/webhook-config-secret branch from 13894c2 to 9d62dbb Compare August 14, 2026 03:53
@trent-hord
trent-hord requested a review from acch August 14, 2026 03:56
@trent-hord
trent-hord marked this pull request as ready for review August 14, 2026 03:56
@trent-hord

trent-hord commented Aug 14, 2026

Copy link
Copy Markdown
Author

Made the changes requested. Ready for review.

@acch

acch commented Aug 15, 2026

Copy link
Copy Markdown
Member

Thank you very much @trent-hord! The code looks good, I'll make a few minor edits before merging it...

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

Labels

bug Something isn't working go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

forgejo_repository_webhook: write-only config.secret causes "inconsistent result after apply"

2 participants