You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: import-dir misclassifies valid primary specifications based on filename #632
import-dir decides whether a specification is a primary or secondary artifact based purely on substring matching against the filename, without inspecting the file contents.
Any filename containing words like examples, metadata, collection, or postman is marked as a secondary artifact (mainArtifact=false).
When a valid primary specification has a name matching any of those substrings (for example payments-examples.yaml or user-metadata-api.yaml), it is uploaded with mainArtifact=false. Because Microcks treats secondary artifacts as completion artifacts that require an already-discovered service, the import fails to discover any API if no separate primary artifact exists.
This also prevents importing standalone Postman collections via import-dir, even though Microcks supports them as primary artifacts.
Root cause
cmd/importDir.go lines 305–325:
funcdetectFileType(filePathstring) FileType {
fileName:=strings.ToLower(filepath.Base(filePath))
ext:=filepath.Ext(filePath)
isPrimary:=trueifstrings.Contains(fileName, "postman") ||strings.Contains(fileName, "collection") ||strings.Contains(fileName, "metadata") ||strings.Contains(fileName, "examples") {
isPrimary=false
}
// If there's an OpenAPI file, prefer it as primaryifstrings.Contains(fileName, "openapi") ||strings.Contains(fileName, "swagger") {
isPrimary=true
}
returnFileType{
Extension: ext,
IsPrimary: isPrimary,
}
}
Substring matching on examples, collection, metadata, or postman forces isPrimary = false on valid specs.
The override at line 317 only checks for openapi or swagger, completely ignoring AsyncAPI, GraphQL, Protobuf, and primary Postman collections.
To reproduce
Put a valid OpenAPI spec in a directory named payments-examples.yaml
Run microcks import-dir .
Notice the CLI reports:
Microcks has completed '...'
instead of discovered. Because it was uploaded with mainArtifact=false and no prior primary spec exists, the service is not discovered.
Suggested fix
Inspect the file contents (e.g. checking for top-level keys like openapi:, swagger:, asyncapi:, or Postman collection structure) to identify primary artifacts, and only use filename heuristics as a fallback.
Activity
gyanranjanpanda commentedon Nov 19, 2026
@Caesarsage @Harsh4902 what is your view on this