--- title: "ADR 0095: Starting a PipelineRun: pending under a concurrency limit, and which failures are fatal" --- * Status: accepted * Code: [`pkg/pipelineascode/pipelineascode.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/pipelineascode/pipelineascode.go) ## Context `startPR` creates the PipelineRun, optionally creates a git auth secret for it, reports a status to the Git provider and patches the run so the watcher picks it up. Several steps can fail after the run exists, and the caller (`Run`) turns every error into a failed check on the provider. ## Decision * When the repository has a non-zero `ConcurrencyLimit`, the run is created with `Spec.Status` pending. Any pending run is reported as queued and patched with the queued state; the code does not distinguish a PAC concurrency limit from another pending cause such as an external mutating webhook. * Only runs carrying the `state` annotation are reconciled by the watcher, so every started run is patched with `StateStarted` or `StateQueued`. * If creation fails, the auto-created git auth secret is deleted, because no owner reference can be set. A failed delete is only logged so it does not hide the creation error. * After creation, failures (owner reference update, status creation) return the created run together with the error, so the caller can still register it in the concurrency manager and run cancel-in-progress. * A failed patch is only logged and `startPR` returns no error: returning one would create a failed check for a run that started. * The log URL is patched only when the run has no installation ID annotation; the reason for that exclusion is not visible in the code. ## Consequences * A failed patch can leave a run without a `state` annotation, which the watcher never reconciles. * The creation error carries markdown (a fenced block) because it is displayed on the provider, which is why it is formatted differently from the errors emitted to the event stream.