import-dir uploads secondary artifacts before their primary API definition
Mantenedores costumam responder em até 3 dias
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 88/100
Direção de pesquisa
Comece em cmd/importDir.go, na parte relacionada à lógica de descoberta e upload de ImportDirectory, e depois adicione ou execute cmd/import_order_regression_test.go. Confirme que openapi.yaml é carregado antes de examples.yaml, preservando a ordem relativa dentro de cada grupo de status primário, e garanta que os testes de cmd passem.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Go
- Estrelas
- 59
- Forks
- 75
- Merge médio
- 7d 12h
- PRs com merge (30d)
- 20
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de microcks/microcks-cli
-
Logging into a locally started instance clears its container reference, causing stop to do nothingAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 79/100
microcks/microcks-cli#620 ·
Mantenedores costumam responder em até 3 dias
-
WatchConfig.UpsertEntry silently deletes existing contexts when re-upserting a watched fileTalvez já em andamento @aryarathoree assumiu há 3 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
microcks/microcks-cli#610 · 5 comentários ·
Mantenedores costumam responder em até 3 dias
-
bug: microcks test get swallows test failure details and operation results in text output modeTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
microcks/microcks-cli#608 · 2 comentários ·
Mantenedores costumam responder em até 3 dias
-
KeycloakClient strips realm path when realm URL lacks trailing slashTalvez já em andamento @aryarathoree assumiu há 3 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
microcks/microcks-cli#606 · 1 comentário ·
Mantenedores costumam responder em até 3 dias
-
Windows test failures in MockFileSystem.Walk due to path separatorTalvez já em andamento @dipak0000812 assumiu há 6 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
microcks/microcks-cli#601 · 1 comentário ·
Mantenedores costumam responder em até 3 dias
Todas as issues de microcks/microcks-cli
Issues semelhantes
-
bug os:ios
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
hajimehoshi/ebiten#4039 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 69/100
open-telemetry/opentelemetry-go-compile-instrumentation#1713 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 77/100
JakeChampion/lang#14392 ·
Mantenedores costumam responder em até 1 dia
-
agent-butler-finding bug
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 84/100
jordansmall/spindrift#6557 ·
Mantenedores costumam responder em até 1 dia