Skip to content

attach: fails with 'failed to get processor' for files without recognized extension #497

@aftersnow

Description

@aftersnow

Description

modctl attach fails when attaching a file whose name does not match any recognized extension pattern. For example, attaching a .metadata file:

modctl attach /.metadata --output-remote \
  -s <source-reference> \
  -t <target-reference> \
  -d <destination-dir> --plain-http --force

Error:

Error: failed to get processor for file /.metadata

Root Cause

getProcessor() in pkg/backend/attach.go matches the file basename against four pattern lists (ConfigFilePatterns, ModelFilePatterns, CodeFilePatterns, DocFilePatterns) using filepath.Match. If no pattern matches, it returns nil, causing the error.

Dotfile matching inconsistency

Due to Go's filepath.Match glob semantics, single-extension dotfiles (e.g., .metadata, .aa) can never be matched by *.<ext> patterns, while double-extension dotfiles (e.g., .aa.bb) can:

File Pattern Match Reason
.aa *.json false * matches empty, .json.aa
.aa *.* true * matches empty, . matches ., * matches aa
.aa.bb *.bb true * matches .aa, .bb = .bb
.aa.json *.json true * matches .aa, .json = .json

All existing patterns are in the *.<ext> form, so any dotfile without a secondary extension is unmatchable by the current pattern lists.

Possible Solutions

  1. Add a fallback processor in getProcessor() for unrecognized file types (e.g., default to doc or config processor)
  2. Add a --media-type flag to attach so users can explicitly specify the media type, bypassing auto-detection
  3. Extend patterns to include dotfiles like .metadata

Option 2 seems the most flexible — it gives users control without guessing intent for unknown file types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions