Skip to content

feat: add structured error codes (PLB-XXXX) with documentation links#93

Open
stephrobert wants to merge 2 commits intogetplumber:mainfrom
stephrobert:feature/error-codes-doc-links
Open

feat: add structured error codes (PLB-XXXX) with documentation links#93
stephrobert wants to merge 2 commits intogetplumber:mainfrom
stephrobert:feature/error-codes-doc-links

Conversation

@stephrobert
Copy link
Contributor

Summary

Add structured error codes (PLB-XXXX) to every issue detected by Plumber, with direct links to dedicated documentation pages.

Changes

New file

  • control/codes.go — Central error code registry with 14 codes (PLB-0101 to PLB-0501), ErrorCode type, ErrorCodeInfo struct, and lookup/listing functions

Modified files

  • control/types.go — Added Code ErrorCode and DocURL string fields to issue structs
  • cmd/analyze.go — Display [PLB-XXXX] prefix on each issue line + ↳ docs: link + Codes column in summary table
  • control/mrcomment.go — Include error codes and doc links in MR comments
  • 10 control files — Assign error codes to all issue creation points

Error Codes

Code Issue Control
PLB-0101 Forbidden image tag containerImageMustNotUseForbiddenTags
PLB-0102 Image not pinned by digest containerImageMustNotUseForbiddenTags
PLB-0103 Unauthorized image source containerImageMustComeFromAuthorizedSources
PLB-0201 Branch not protected branchMustBeProtected
PLB-0202 Non-compliant branch protection branchMustBeProtected
PLB-0301 Hardcoded job pipelineMustNotIncludeHardcodedJobs
PLB-0302 Outdated include version includesMustBeUpToDate
PLB-0303 Forbidden include version includesMustNotUseForbiddenVersions
PLB-0401 Required component missing pipelineMustIncludeComponent
PLB-0402 Required component overridden pipelineMustIncludeComponent
PLB-0403 Required template missing pipelineMustIncludeTemplate
PLB-0404 Required template overridden pipelineMustIncludeTemplate
PLB-0501 Debug trace enabled pipelineMustNotEnableDebugTrace

CLI Output Example

[PLB-0101] Job "build" uses image "node:latest" with forbidden tag "latest"
  ↳ docs: https://getplumber.io/e/PLB-0101

Summary table now includes a Codes column with links to documentation.

Documentation

Companion PR for doc pages: getplumber/getplumber.io#77

Closes #92

@Joseph94m
Copy link
Collaborator

Joseph94m commented Mar 5, 2026

Hello @stephrobert , thanks for the contribution.

  • I did the tests and the review and it seems good
  • I rebased on main which contains a new control and updated that new control to receive this branch's updates.
  • If you want to perform any more operations on this branch, you have to pull --rebase

I have 1 question about the PR:

For example in the following configuration found in codes.go, we only ever use the Code and the DocURL in the codebase. Do you intended to use the other fields such as description and remediation?

	CodeDebugTraceEnabled: {
		Code:        CodeDebugTraceEnabled,
		Title:       "Debug trace enabled",
		Description: "The pipeline has CI_DEBUG_TRACE or CI_DEBUG_SERVICES enabled, which exposes all secret variables in the job log output. This is a critical security risk in production pipelines.",
		Remediation: "Remove or set CI_DEBUG_TRACE and CI_DEBUG_SERVICES to 'false' in your .gitlab-ci.yml variables section. These should only be used temporarily for debugging and never committed.",
		DocURL:      docsBaseURL + string(CodeDebugTraceEnabled),
		ControlName: "pipelineMustNotEnableDebugTrace",
	},

Also, for commits. use feat(scope): notation instead of feat: . In this case, the scope would have been analysis

@Joseph94m Joseph94m force-pushed the feature/error-codes-doc-links branch from 7f8254b to 7b8073d Compare March 5, 2026 09:20
@Joseph94m
Copy link
Collaborator

Activated branch protection and copilot should review

stephrobert and others added 2 commits March 5, 2026 14:08
- Add control/codes.go with 14 error codes (PLB-0101 to PLB-0501)
- Add Code and DocURL fields to all issue structs
- Display [PLB-XXXX] prefix and docs link in CLI output
- Add Codes column to summary table with docs footer
- Include error codes and doc links in MR comments

Closes getplumber#92
- Add url and code information to new control that are on main
- Refactor branchProtection control's specific structures to their appropriate files
Copilot AI review requested due to automatic review settings March 5, 2026 13:08
@Joseph94m Joseph94m force-pushed the feature/error-codes-doc-links branch from 7b8073d to a83e326 Compare March 5, 2026 13:08
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

@Joseph94m
Copy link
Collaborator

@copilot code review[agent] review please

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Add error codes and documentation links to control findings (Popeye-style codes.md)

3 participants