--- title: "ADR 0092: Access check on comments is deferred, and annotation matching runs more than once" --- * Status: accepted * Code: [`pkg/pipelineascode/match.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/pipelineascode/match.go) ## Context `verifyRepoAndUser` decides whether the sender may trigger CI, and `getPipelineRunsFromRepo` matches definitions to the event. For comment events the matching changes the event itself, so the order of the two matters. ## Decision * On push, the policy check is skipped, since a pusher already has access, except for a GitOps command on a push commit, where any user can comment and is checked. * For events other than push and no-ops comments, `checkAccessOrError` runs in `verifyRepoAndUser`. After approval by `/ok-to-test`, the parent status is set to success only when `InstallationID <= 0`: GitHub App events use check runs and are not updated this way. * For `NoOpsCommentEventType` and `OnCommentEventType` events the check is skipped in `verifyRepoAndUser` and repeated in `getPipelineRunsFromRepo` after matching. The code comment says this is done for comment events that matched no `on-comment` key; why it cannot run earlier is not visible in the code. * Before templating, `MatchPipelinerunByAnnotation` is called once with its result ignored, when no `/test` target is set. It expands dynamic event values (for example `event_type` becoming `on-comment`) that the templating reads. The matching then runs again with the real result, and a third time after resolution. The earlier code comment judged merging the three calls too risky for behaviour; nothing in the code enforces that. * A `MetadataResolve` error on a no-ops comment event is logged and not reported: reporting creates a comment, which triggers another webhook with the same error. ## Consequences * Matching cost is paid up to three times per event. * A comment that matches no `on-comment` annotation is access-checked after the templates have been fetched and parsed.