Repository navigation
Closed
Labels
Description
Source PR: #388
Branch: fix/target-dir-shared-validation
Head reviewed: 1227271
Push the fixes to the branch above; do not open a new pull request. Comment on the PR and on this issue when done.
Blocking findings
- Issue doctor --target-dir accepts relative paths while install refuses them as invalid_target #372 criterion satisfied only for relative/unclean targets; doctor and update still accept absolute targets install refuses as invalid_target (
internal/cli/doctor.go:122): Issue doctor --target-dir accepts relative paths while install refuses them as invalid_target #372's Expected direction is explicit: 'a target that install would refuse as invalid_target should be refused the same way by every command that consumes --target-dir, so the directory-target contract stays consistent across the CLI.' At the reviewed head the shared guard validTargetDir (install.go:102) checks only path form (absolute + clean). install additionally refuses any absolute target that is missing or not a directory as error=invalid_target, exit 64 (install.go:119-121). doctor still forwards such a target at doctor.go:122 and reports presence=absent with exit 0 (doctor.go:134); a regular file yields presence=unreadable with exit 3 (exitConflict). update still stats the path at update.go:243 and returns reason=target_absent with exit 2 (writeUpdateRefusal returns exitUnknown=2). docs/operating.md:81, untouched by this PR, documents install's refusal set as 'the path is missing, relative, or not a directory', while the sentence added by this PR at docs/operating.md:82 claims only 'a relative or unclean --target-dir' is refused by doctor, update, and uninstall - the PR narrows the stated scope without reconciling it with the issue criterion or listing it under its Out of Scope section. The new test TestDirectoryTargetCommandsRefuseRelativeTargets exercises only relative and unclean targets, so the divergence is covered by no assertion. Note for triage: doctor's documented contract (docs/operating.md table) is to report a directory target's presence, so the issue criterion as written and the preserved presence=absent behavior are in tension - the intended scope needs an explicit decision rather than the silent narrowing.- Failure scenario: Given the absolute path /abs/missing that does not exist:
cortex install --target-dir /abs/missingexits 64 with stderr error=invalid_target, butcortex doctor --target-dir /abs/missingexits 0 with stdouttarget=/abs/missing presence=absent, andcortex update --target-dir /abs/missing --catalog <catalog> --applyexits 2 with stdout endingreason=target_absent- none of them refuses the target the way install would, contradicting the quoted criterion. Given an absolute path that is a regular file: install exits 64 error=invalid_target, doctor exits 3 presence=unreadable, update exits 2 reason=target_absent. The commands still disagree on what a valid target is, which is the exact inconsistency doctor --target-dir accepts relative paths while install refuses them as invalid_target #372 reports.
- Failure scenario: Given the absolute path /abs/missing that does not exist:
Acceptance criteria
- Fixed: Issue doctor --target-dir accepts relative paths while install refuses them as invalid_target #372 criterion satisfied only for relative/unclean targets; doctor and update still accept absolute targets install refuses as invalid_target (internal/cli/doctor.go:122). The scenario below no longer reproduces: Given the absolute path /abs/missing that does not exist:
cortex install --target-dir /abs/missingexits 64 with stderr error=invalid_target, butcortex doctor --target-dir /abs/missingexits 0 with stdouttarget=/abs/missing presence=absent, andcortex update --target-dir /abs/missing --catalog <catalog> --applyexits 2 with stdout endingreason=target_absent- none of them refuses the target the way install would, contradicting the quoted criterion. Given an absolute path that is a regular file: install exits 64 error=invalid_target, doctor exits 3 presence=unreadable, update exits 2 reason=target_absent. The commands still disagree on what a valid target is, which is the exact inconsistency doctor --target-dir accepts relative paths while install refuses them as invalid_target #372 reports.
Activity
barbatjuan commentedon Oct 24, 2026
Status at head ccf3ebf of #388: relative, unclean, trailing-separator, and empty targets are now refused as
invalid_target(exit 64) by every--target-dircommand. The remaining item here needs your ruling before I change code, because two of your own texts point in different directions:invalid_target"should be refused the same way by every command", which literally includes a missing or non-directory absolute path.Today, with the built binary at ccf3ebf:
invalid_targetpresence=absentreason=target_absentnot_installedinvalid_targetpresence=unreadablereason=target_absentuninstall_observation_failedOptions:
invalid_target(it has nothing to update), and keep doctor's presence report. This is my recommendation.presence=absent, so its feat: report directory targets in cortex doctor #343 contract and docs change too.Once you pick one, I'll push it to
fix/target-dir-shared-validationwith tests and docs, and fold in the remaining non-blocking suggestions from the latest reviews in the same push (fixture outside the source tree, a duplicate-flag subtest, a runtime-mode control case, and refusing the contradictory--runtime "" --target-dir <dir>).barbatdev commentedon Nov 12, 2026
Maintainer decision (option 2):
update --target-dirrefuses an absolute target that is missing or not a directory asinvalid_target(exit 64), the same asinstall.doctorkeeps reportingpresence=absentwithout refusing. Note: #358 (PR #430) makesuninstall --target-diron a missing root fail closed (exit 3); #388 must be rebased on it and keep both behaviors.fix(cli): refuse missing or non-directory update targets as invalid_t…
barbatdev commentedon Nov 12, 2026
Implemented on #388 in 79102df (option 2).
fix(cli): refuse relative --target-dir in doctor, update, and uninsta…
barbatdev commentedon Nov 12, 2026
Implemented by #388 (merged 46f2870):
update --target-dirrefuses a missing or non-directory absolute target asinvalid_target, exit 64.doctorkeepspresence=absent, exit 0.uninstallkeeps exit 3 from #358. Covered byTestUpdateDirectoryTargetRefusesMissingOrNonDirectoryandTestDoctorDirectoryTargetReportsMissingAsAbsent.