Skip to content

Fix crash when .dockerignore is missing during cloud build#315

Merged
danielmillerp merged 1 commit intomainfrom
dm/fix-missing-dockerignore
Apr 9, 2026
Merged

Fix crash when .dockerignore is missing during cloud build#315
danielmillerp merged 1 commit intomainfrom
dm/fix-missing-dockerignore

Conversation

@danielmillerp
Copy link
Copy Markdown
Contributor

@danielmillerp danielmillerp commented Apr 9, 2026

Summary

  • BuildContextManager.__enter__ crashes with FileNotFoundError when a manifest declares a .dockerignore path but the file doesn't exist on disk
  • This causes sgpctl agentex-cloud build submit to fail for any agent created without a .dockerignore (e.g. manually created agents that didn't use agentex init)
  • Fix: check if the file exists before attempting to copy/parse it, log a warning, and proceed with no ignore patterns

Test plan

  • Verify cloud build succeeds for an agent with .dockerignore present (no behavior change)
  • Verify cloud build succeeds for an agent without .dockerignore (previously crashed, now warns and continues)

🤖 Generated with Claude Code

Greptile Summary

Adds a dockerignore_path.exists() guard in BuildContextManager.__enter__ so a missing .dockerignore file emits a warning and falls back to an empty ignore-patterns list instead of raising FileNotFoundError. The change is minimal, correctly scoped, and the existing ignore_patterns = [] initialisation on line 92 ensures directory-copy logic downstream still receives a valid list.

Confidence Score: 5/5

Safe to merge — fix is minimal, correct, and handles the missing-file case gracefully with no regressions.

No P0 or P1 findings. The existence check is correctly placed, ignore_patterns is already initialised to [] before the guard so downstream logic is unaffected, and the warning follows the f-string logging convention used throughout the file.

No files require special attention.

Vulnerabilities

No security concerns identified. The new warning log records a local file path, which is expected and benign in a build-tool context.

Important Files Changed

Filename Overview
src/agentex/lib/sdk/config/agent_manifest.py Adds existence check before copying/parsing .dockerignore; gracefully warns and continues when file is absent. Logic is correct and consistent with the rest of the file's f-string logging style.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[__enter__ called] --> B[Copy Dockerfile to temp dir]
    B --> C{dockerignore path configured?}
    C -- No --> F[ignore_patterns = empty list]
    C -- Yes --> D{dockerignore_path.exists?}
    D -- Yes --> E[Copy .dockerignore and extract patterns]
    D -- No --> G[Log warning, keep ignore_patterns empty]
    E --> H[add_directory for each include_path]
    F --> H
    G --> H
    H --> I[Return self]
Loading

Reviews (1): Last reviewed commit: "Fix crash when .dockerignore file is mis..." | Re-trigger Greptile

The build context preparation crashes with FileNotFoundError when a
manifest specifies a dockerignore path but the file doesn't exist on
disk. This adds an existence check and logs a warning instead of
crashing, so builds proceed with no ignore patterns.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@danielmillerp danielmillerp merged commit 67c38ee into main Apr 9, 2026
32 checks passed
@danielmillerp danielmillerp deleted the dm/fix-missing-dockerignore branch April 9, 2026 02:25
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.

1 participant