feat(prinfo): expand author field to include account type#2934
Merged
javirln merged 5 commits intochainloop-dev:mainfrom Mar 24, 2026
Merged
feat(prinfo): expand author field to include account type#2934javirln merged 5 commits intochainloop-dev:mainfrom
javirln merged 5 commits intochainloop-dev:mainfrom
Conversation
Add PR info schema v1.3 where author accepts both a string (backwards compatible) and an object with login and type fields (User/Bot/unknown). GitHub populates the type from the event payload's user.type field. GitLab sets type to "unknown" since CI env vars don't expose it. This enables policies to check author type directly instead of relying on naming conventions like the [bot] suffix. Signed-off-by: Javier Rodriguez <javier@chainloop.dev>
There was a problem hiding this comment.
1 issue found across 7 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="internal/prinfo/prinfo.go">
<violation number="1" location="internal/prinfo/prinfo.go:49">
P1: This change breaks runtime backward compatibility for old PR info payloads with string `author`: decoding fails before schema validation can apply the v1.3 `oneOf` rule.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Add Data.UnmarshalJSON to handle both string (v1.0-v1.2) and object
(v1.3) author formats at the Go struct level. String authors are
converted to Author{Login: str, Type: "unknown"}.
Also fixes gofmt formatting issues in prmetadata.go and test files.
Signed-off-by: Javier Rodriguez <javier@chainloop.dev>
There was a problem hiding this comment.
1 issue found across 4 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="internal/prinfo/prinfo.go">
<violation number="1" location="internal/prinfo/prinfo.go:80">
P2: Unmarshaling JSON `null` into a struct value leaves it as an empty struct rather than `nil`. Unmarshal into a pointer instead to properly handle nulls.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Refactor fetchGitLabReviewers into fetchGitLabMRDetails to extract both author and reviewer information from the MR API response in a single call. Uses the GitLab `bot` boolean field to set author/reviewer type to "User" or "Bot". Falls back to GITLAB_USER_LOGIN with type "unknown" if the API call fails (best-effort). Signed-off-by: Javier Rodriguez <javier@chainloop.dev>
Address review feedback: explicitly check for JSON null in the author field to prevent unmarshaling null into an empty struct. Signed-off-by: Javier Rodriguez <javier@chainloop.dev>
jiparis
approved these changes
Mar 24, 2026
Piskoo
approved these changes
Mar 24, 2026
Address goconst lint: extract repeated "User", "Bot", "unknown" strings into AuthorTypeUser, AuthorTypeBot, AuthorTypeUnknown constants in the prinfo package. Signed-off-by: Javier Rodriguez <javier@chainloop.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
authorfield in PR info from a plain string to an object withloginandtype(User/Bot/unknown), enabling policies to distinguish bot-authored PRs without relying on naming conventionsoneOfsupporting both string (backwards compat) and object formatsUnmarshalJSONonDatahandles both formats at the Go struct level, converting legacy string authors toAuthor{Login: str, Type: "unknown"}user.typefield)fetchGitLabReviewersintofetchGitLabMRDetailsto extract author bot status from the MR API (author.botfield) in a single call, with fallback to env var if API unavailable