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
- Add a fallback processor in
getProcessor() for unrecognized file types (e.g., default to doc or config processor)
- Add a
--media-type flag to attach so users can explicitly specify the media type, bypassing auto-detection
- Extend patterns to include dotfiles like
.metadata
Option 2 seems the most flexible — it gives users control without guessing intent for unknown file types.
Description
modctl attachfails when attaching a file whose name does not match any recognized extension pattern. For example, attaching a.metadatafile:Error:
Root Cause
getProcessor()inpkg/backend/attach.gomatches the file basename against four pattern lists (ConfigFilePatterns,ModelFilePatterns,CodeFilePatterns,DocFilePatterns) usingfilepath.Match. If no pattern matches, it returnsnil, causing the error.Dotfile matching inconsistency
Due to Go's
filepath.Matchglob semantics, single-extension dotfiles (e.g.,.metadata,.aa) can never be matched by*.<ext>patterns, while double-extension dotfiles (e.g.,.aa.bb) can:.aa*.json*matches empty,.json≠.aa.aa*.**matches empty,.matches.,*matchesaa.aa.bb*.bb*matches.aa,.bb=.bb.aa.json*.json*matches.aa,.json=.jsonAll existing patterns are in the
*.<ext>form, so any dotfile without a secondary extension is unmatchable by the current pattern lists.Possible Solutions
getProcessor()for unrecognized file types (e.g., default to doc or config processor)--media-typeflag toattachso users can explicitly specify the media type, bypassing auto-detection.metadataOption 2 seems the most flexible — it gives users control without guessing intent for unknown file types.