Skip to content

fix(pkg/yamlprocessor): guard GetValue, ReplaceString, and Bytes against nil processor - #7378

Closed
Norway-02 wants to merge 1 commit into
pipe-cd:masterfrom
Norway-02:fix/yamlprocessor-nil-guard
Closed

fix(pkg/yamlprocessor): guard GetValue, ReplaceString, and Bytes against nil processor#7378
Norway-02 wants to merge 1 commit into
pipe-cd:masterfrom
Norway-02:fix/yamlprocessor-nil-guard

Conversation

@Norway-02

Copy link
Copy Markdown

What this PR does:
Adds defensive nil-receiver and uninitialized AST file pointer guards (p == nil || p.file == nil) to GetValue(), ReplaceString(), and Bytes() in pkg/yamlprocessor.

Why we need it:
Calling GetValue(), ReplaceString(), or Bytes() on an uninitialized or nil *Processor previously caused an unhandled runtime error: invalid memory address or nil pointer dereference panic. Adding these checks prevents panics and safely returns clean error messages or nil byte slices.

Which issue(s) this PR fixes:
Fixes # NONE

Does this PR introduce a user-facing change?:

  • How are users affected by this change: None
  • Is this breaking change: No
  • How to migrate (if breaking change): N/A

Screenshots/Videos (for documentation or website changes):
N/A

…nst nil processor

Signed-off-by: Norway-02 <anshulkhetade02@gmail.com>
Copilot AI lite review requested due to automatic review settings September 12, 2026 15:14
@Norway-02
Norway-02 requested a review from a team as a code owner September 12, 2026 15:14
@Norway-02

Copy link
Copy Markdown
Author

cc @mohammedfirdouss @TheRealShek @Warashi - Please review when you get a chance. Thanks!

@netlify

netlify Bot commented Sep 12, 2026

Copy link
Copy Markdown

Deploy Preview for pipecd-site ready!

Name Link
🔨 Latest commit 71b404a
🔍 Latest deploy log https://app.netlify.com/projects/pipecd-site/deploys/6aa56c75692ceb00088c4baf
😎 Deploy Preview https://deploy-preview-7378--pipecd-site.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No unresolved review issues were identified.

Pull request overview

Adds nil-safety guards to YAML processor methods, preventing panics for nil or uninitialized processors.

Changes:

  • Guards GetValue, ReplaceString, and Bytes.
  • Adds regression tests for nil and uninitialized processors.
File summaries
File Description
pkg/yamlprocessor/yamlprocessor.go Adds defensive nil and file checks.
pkg/yamlprocessor/yamlprocessor_test.go Tests nil and uninitialized processor behavior.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@armistcxy

Copy link
Copy Markdown
Contributor

Thanks for the PR, but I don't think this change is warranted. NewProcessor() is the only way to construct a *Processor and it either returns (nil, err) on failure or a fully-initialized &Processor{file: f} on success

@armistcxy armistcxy closed this Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants