Skip to content

Commit 0c5a35c

Browse files
aledbfclaude
andcommitted
fix(parity): 3 divergencias TS↔Go destapadas por la auditoría de cobertura
Encontradas por el workflow parity-coverage-audit (huecos de cobertura que escondían bugs), verificadas contra el oráculo TS: - up --workspace-mount-consistency: faltaba validar el enum [consistent,cached,delegated]; Go pasaba cualquier string a docker. Ahora se valida como en TS (yargs choices). -> exit 1 = TS. - features/templates package|publish --log-level: StringVar sin validar; MapLogLevel defaulteaba silenciosamente a Info. Ahora rechaza fuera de rango [info,debug,trace] (collectionCommonUtils/{package,publish}.ts). -> exit 1 = TS. - features resolve-dependencies sin features: Go imprimía {"installOrder":[]} exit 0; TS escribe 'Could not parse features object...' a stderr y exit 1 (resolveDependencies.ts:92-93). Corregido, mensaje idéntico. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent f069ff9 commit 0c5a35c

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

internal/cli/collection_commands.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,11 @@ func realFeaturesTestCmd() *cobra.Command {
252252
// --- Shared implementation ---
253253

254254
func packageCollection(targetFolder, outputDir, collectionType string, forceClean bool, logLevelStr string) error {
255+
// TS parity: --log-level is a yargs choice; reject out-of-range instead of
256+
// silently defaulting to Info (collectionCommonUtils/package.ts:18).
257+
if err := validateEnum("log-level", logLevelStr, []string{"info", "debug", "trace"}); err != nil {
258+
return err
259+
}
255260
logger := log.New(log.Options{
256261
Level: log.MapLogLevel(logLevelStr),
257262
Format: "text",
@@ -339,6 +344,11 @@ func packageCollection(targetFolder, outputDir, collectionType string, forceClea
339344
// with a fake oci.Registry and a capturing Output to drive the partial-publish
340345
// error path hermetically.
341346
func publishCollection(targetFolder, registry, namespace, collectionType, logLevelStr string) error {
347+
// TS parity: --log-level is a yargs choice; reject out-of-range instead of
348+
// silently defaulting to Info (collectionCommonUtils/publish.ts:14).
349+
if err := validateEnum("log-level", logLevelStr, []string{"info", "debug", "trace"}); err != nil {
350+
return err
351+
}
342352
logger := log.New(log.Options{
343353
Level: log.MapLogLevel(logLevelStr),
344354
Format: "text",

internal/cli/features_resolve_deps.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"path/filepath"
88

99
"github.com/devcontainers/cli/internal/config"
10+
coreerrors "github.com/devcontainers/cli/internal/errors"
1011
"github.com/devcontainers/cli/internal/features"
1112
"github.com/devcontainers/cli/internal/log"
1213
"github.com/devcontainers/cli/internal/oci"
@@ -44,8 +45,11 @@ func realFeaturesResolveDepsCmd() *cobra.Command {
4445
cfg := loadResult.Config
4546
userFeatures := features.UserFeaturesToArray(cfg.Features)
4647
if len(userFeatures) == 0 {
47-
fmt.Fprintln(out.Stdout(), `{"installOrder":[]}`)
48-
return nil
48+
// TS parity: no parseable features → stderr error + exit 1
49+
// (featuresCLI/resolveDependencies.ts:92-93), NOT an empty
50+
// installOrder on stdout.
51+
logger.Write(fmt.Sprintf("Could not parse features object in configuration '%s'", cfg.ConfigFilePath), log.LevelError)
52+
return &coreerrors.ExitCodeError{Code: 1}
4953
}
5054

5155
ociClient := oci.NewClient(logger, osEnvMap())

internal/cli/up.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ func runUp(ctx context.Context, out Output, opts *upOpts) error {
172172
{"log-level", opts.logLevel, []string{"info", "debug", "trace"}},
173173
{"log-format", opts.logFormat, []string{"text", "json"}},
174174
{"buildkit", opts.buildkit, []string{"auto", "never"}},
175+
{"workspace-mount-consistency", opts.workspaceMountConsistency, []string{"consistent", "cached", "delegated"}},
175176
{"gpu-availability", opts.gpuAvailability, []string{"all", "detect", "none"}},
176177
{"default-user-env-probe", opts.defaultUserEnvProbe, []string{"none", "loginShell", "interactiveShell", "loginInteractiveShell"}},
177178
{"update-remote-user-uid-default", opts.updateRemoteUserUIDDefault, []string{"on", "off", "never"}},

0 commit comments

Comments
 (0)