Fix builds:output exiting 0 for unknown build ids

When the per-build log is missing, builds:output fell through to
journalctl without checking that the build record exists. A typo'd or
never-recorded id then printed nothing and exited 0.

Validate the build record first and return "no such build" when it is
absent. Existing records with pruned logs still use the journalctl
fallback.

Fixes #9031
This commit is contained in:
Jason Wang committed 2026-09-11 20:54:50 +00:00
1 parent aa39920cc7
commit cbaea8161d
2 files changed
+58

No files matched your search

+8
View File
@@ -381,6 +381,14 @@ func CommandOutput(appName, buildID string) error {
logPath := LogPathFor(appName, buildID)
if _, err := os.Stat(logPath); err != nil {
if os.IsNotExist(err) {
// A missing log is normal after prune/rotation, but a typo'd or
// never-recorded id must not fall through to journalctl and exit 0.
if _, err := ReadBuild(appName, buildID); err != nil {
if os.IsNotExist(err) {
return fmt.Errorf("no such build %s for app %s", buildID, appName)
}
return err
}
return outputViaJournalctl(buildID)
}
return err