--- title: "ADR 0059: Resource precedence and annotation validation when resolving PipelineRuns" --- * Status: accepted * Code: [`pkg/resolve/resolve.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/resolve/resolve.go), [`pkg/resolve/remote.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/resolve/remote.go) ## Context `resolveRemoteResources` inlines tasks and pipelines into each PipelineRun. They can come from the PipelineRun annotations, the Pipeline annotations (remote fetches), or the `.tekton` directory. Fetched resources are cached per event, and run-specific resources are kept separately. ## Decision * Task precedence: PipelineRun annotations, then Pipeline annotations, then the `.tekton` directory. A task already present in the run-specific resources is not added again, which gives that order. * Pipeline precedence: PipelineRun annotation first, then the `.tekton` directory. A pipeline already fetched for the event is deep-copied so inlining for one run does not mutate the cached original. * If the pipeline fetched from the annotation does not have the name of the `pipelineRef`, a local pipeline of that name is looked up instead. * `getPipelineByName` returns the first Pipeline with the name and does not handle conflicts. * Relative task references are expanded against the pipeline URL only when it is HTTP(S) or a repository path. Hub references such as `catalog://resource:version` use another scheme where relative paths are meaningless. Tasks that already have a valid URL are skipped. * Annotations are validated after labels and annotations are initialised to avoid a nil pointer; one invalid run fails the whole resolve with an error naming it. * Labels and annotations set by the user are never overwritten; the original name goes in `OriginalPRName` for later grouping and cleanup. ## Consequences * Two pipelines with the same name in `.tekton` silently resolve to the first. * One invalid PipelineRun blocks all other runs of the push.