Skip to content

Add exception handling for non-Dockerfile formats - #1883

Merged
Julian (jpinz) merged 5 commits into
mainfrom
jupinzer/dockerfile_exception_handling
Sep 30, 2026
Merged

Julian (jpinz) merged 5 commits into
mainfrom
jupinzer/dockerfile_exception_handling

Conversation

@jpinz

@jpinz Julian (jpinz) commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

This pull request improves the Dockerfile component detector's handling of files that are named like Dockerfiles but contain other formats. Parse failures are now treated as expected non-Dockerfile input and logged as warnings, while other processing failures remain errors.

The detector also skips files under node_modules, where packages may include Dockerfile language definitions that are not build instructions. Tests cover JavaScript content in dockerfile.mjs and dockerfile.d.mts, as well as a Dockerfile-like file under node_modules, ensuring these files do not produce false positives.

@jpinz
Julian (jpinz) requested a review from a team as a code owner September 30, 2026 19:23
@jpinz
Julian (jpinz) requested review from Aayush Maini (AMaini503) and a balanced review from Copilot and removed request for Copilot September 30, 2026 19:23
Copilot AI balanced review requested due to automatic review settings September 30, 2026 19:30

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.

Copilot review overview

🟡 Changes recommended

Tests do not verify the new logging behavior, and Sprache lacks a direct package reference.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Improves Dockerfile detector handling of non-Dockerfile content.

Changes:

  • Treats parser failures as warnings.
  • Adds tests for Shiki JavaScript definition files.
File Description
DockerfileComponentDetector.cs Adds specialized parse-error handling.
DockerfileComponentDetectorTests.cs Adds non-Dockerfile test cases.

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

Copilot AI balanced review requested due to automatic review settings September 30, 2026 20:02
@github-actions

Copy link
Copy Markdown

👋 Hi! It looks like you modified some files in the Detectors folder.
You may need to bump the detector versions if any of the following scenarios apply:

  • The detector detects more or fewer components than before
  • The detector generates different parent/child graph relationships than before
  • The detector generates different devDependencies values than before

If none of the above scenarios apply, feel free to ignore this comment 🙂

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.

Copilot review overview

🟡 Changes recommended

Dependency declaration, logging verification, and the undocumented blanket node_modules exclusion need resolution.

Review effort: Balanced
Findings: 3 Medium severity · 1 Low severity

Open (4)

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.

One nitpick that the bot had already made, but don't block on if it's going to be annoying.

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.

Copilot review overview

🔵 Needs a closer look

The output-changing exclusion requires incrementing the detector version.

Review effort: Balanced
Findings: None

Resolved since last review (4)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Increment detector version when excluding node_modules components

src/​Microsoft.ComponentDetection.Detectors/​dockerfile/​DockerfileComponentDetector.cs:47

Skipping every matching file under node_modules intentionally removes components that version 1 previously reported, but the detector version is unchanged. The repository requires detector versions to be incremented for breaking output changes (docs/creating-a-new-detector.md:178), and verification uses version increases to identify intentional detector changes (ComponentDetectionIntegrationTests.cs:240-265). Increment this detector to version 2 with the new exclusion.

Copilot AI balanced review requested due to automatic review settings September 30, 2026 21:02

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.

Copilot review overview

🔵 Needs a closer look

The detector version must be incremented for the breaking output change.

Review effort: Balanced
Findings: None

Previously missed (1)

In code that hasn't changed since last review

Medium severity Bump detector version for breaking output change

src/​Microsoft.ComponentDetection.Detectors/​dockerfile/​DockerfileComponentDetector.cs:45

Skipping an entire path class can remove DockerReference components that version 1 previously reported, so this is a breaking detector-output change. The repository's detector guidance requires incrementing Version for breaking changes (docs/creating-a-new-detector.md:176-179); bump this detector to version 2 so consumers can identify the changed results.

@jpinz
Julian (jpinz) merged commit b44ed37 into main Sep 30, 2026
15 checks passed
@jpinz
Julian (jpinz) deleted the jupinzer/dockerfile_exception_handling branch September 30, 2026 21:13
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.

4 participants