import-dir uploads secondary artifacts before their primary API definition
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 88/100
Línea de trabajo
Comienza en cmd/importDir.go, alrededor de la lógica de descubrimiento y carga de ImportDirectory, y después añade o ejecuta cmd/import_order_regression_test.go. Confirma que openapi.yaml se carga antes que examples.yaml, manteniendo el orden relativo dentro de cada grupo de estado primario, y asegúrate de que las pruebas de cmd pasen.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Problem
import-dir can upload a secondary artifact before its primary API definition. For example, a directory containing examples.yaml and openapi.yaml uploads examples.yaml with primary=false first, then openapi.yaml with primary=true.
ImportDirectory uploads files in their discovery order. RealFileSystem uses filepath.Walk, so lexical filename order determines which artifact is uploaded first; the files are not grouped by primary/secondary status.
The multi-artifact documentation explains that a secondary artifact is ignored when its matching API name/version does not yet exist. On a first import, this ordering can therefore leave the API without the examples from its secondary artifact.
Expected behavior
Upload primary artifacts before secondary artifacts, regardless of filename order, so the API definition exists before its secondary artifacts are imported.
Reproduction test
Tested on upstream master at e54dc4719d1f14085f5bb551a910139628babbbc, with go version go1.26.5 darwin/arm64 (macOS, ARM64).
Save this as cmd/import_order_regression_test.go and run:
go test ./cmd -run '^TestReviewImportDirPrimaryOrder$' -count=1 -v
The test calls the production ImportDirectory with RealFileSystem and records calls to the upload client. Fixture contents are placeholders because the recording client does not parse them.
package cmd
import (
"fmt"
"os"
"path/filepath"
"testing"
)
type reviewUploadClient struct{ calls []string }
func (c *reviewUploadClient) UploadArtifact(path string, primary bool) (string, error) {
c.calls = append(c.calls, fmt.Sprintf("%s primary=%t", filepath.Base(path), primary))
return "accepted", nil
}
func TestReviewImportDirPrimaryOrder(t *testing.T) {
dir := t.TempDir()
for _, name := range []string{"examples.yaml", "openapi.yaml"} {
if err := os.WriteFile(filepath.Join(dir, name), []byte("fixture"), 0600); err != nil {
t.Fatal(err)
}
}
client := &reviewUploadClient{}
result, err := ImportDirectory(client, &RealFileSystem{}, dir, ImportConfig{})
if err != nil {
t.Fatal(err)
}
t.Logf("upload order: %v; success=%d failed=%d", client.calls, result.SuccessCount, result.FailedCount)
if client.calls[0] != "openapi.yaml primary=true" {
t.Errorf("secondary artifact uploaded before the primary API definition")
}
}
Actual test output
For the recorded run, the test file was supplied through a temporary Go overlay to leave the checkout unchanged:
go test -overlay=/tmp/microcks-import-order-overlay.json ./cmd -run '^TestReviewImportDirPrimaryOrder$' -count=1 -v
=== RUN TestReviewImportDirPrimaryOrder
Microcks has completed 'accepted'
Microcks has discovered 'accepted'
import_order_regression_test.go:29: upload order: [examples.yaml primary=false openapi.yaml primary=true]; success=2 failed=0
import_order_regression_test.go:31: secondary artifact uploaded before the primary API definition
--- FAIL: TestReviewImportDirPrimaryOrder (0.00s)
FAIL
FAIL github.com/microcks/microcks-cli/cmd 0.917s
FAIL
Exit status: 1. The secondary artifact was uploaded first.
This test confirms the CLI upload order only. The accepted responses and success counters come from the recording client, not a live Microcks server. The missing-examples impact follows from the documented secondary-artifact behavior; I have not run a live-server reproduction.
A possible fix is to stably group the discovered files by IsPrimary before uploading them, keeping the existing relative order within each group.
I searched existing issues and PRs for import-dir ordering/primary/secondary reports and found no matching report. PR #459 concerns import-url success-message wording, not directory upload ordering.
- Lenguaje dominante
- Go
- Estrellas
- 57
- Forks
- 72
- Merge medio
- 1 d 8 h
- PR fusionados (30 d)
- 28
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microcks/microcks-cli
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
microcks/microcks-cli#572 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
microcks/microcks-cli#559 · 2 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
TEST: `ConnectAndGetToken` Returns Error on Non-200 ResponsePosiblemente ocupada @aniket866 la tomó hace 7 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
microcks/microcks-cli#554 ·
Los mantenedores suelen responder en 1 día
-
Empty `AuthToken` Causes Cryptic JWT Parse ErrorPosiblemente ocupada @aniket866 la tomó hace 7 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
microcks/microcks-cli#551 ·
Los mantenedores suelen responder en 1 día
-
bug: CLI hangs indefinitely during network failures due to missing `http.Client` timeoutsPosiblemente ocupada @aniket866 la tomó hace 9 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
microcks/microcks-cli#545 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de microcks/microcks-cli
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
golang/go#82033 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 90/100
FootprintAI/Containarium#2338 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: core doesn't build standalone on dev since a17068054 (go-mp3 require dropped, go.sum pruned)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
SagerNet/sing-openvpn#11 ·
-
priority: P3 type: devops
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
jiegui2025/hwspec#57 ·
Los mantenedores suelen responder en 1 día