Audit run_rc()/run() callers for correct cause vs. raw-output distinction #56

Open
opened 2026-08-16 08:58:54 +02:00 by michael · 0 comments
Owner

Problem

fs/dir.lua's remove_dir_recursive() currently (pre-#48-fix) passes
sys:run_rc()'s second return value as cause in both branches:

local rc, output = sys:run_rc("rm -rf -- " .. shell_quote(path))
if rc == nil then
  return err("rm_failed", "rm invocation failed", { cause = output, data = { path = path } })
end

sys.lua's run_rc() contract: on infrastructure failure it returns
nil, daw_error/v1 (output is a valid cause there); on a completed
process with non-zero exit, it returns rc, stdout (output is raw
process text, never a daw_error/v1, and must not be used as cause).

Found and fixed for fs/dir.lua's own two call sites during the
daw_i18n/v1 migration (DAW/daw-lua-common#48). This issue is to audit
whether other run_rc()/run() callers in the library make the same
mistake.

Scope

  • Audit all run_rc()/run() callers for the rc==nil vs rc!=0 (or
    equivalent) distinction
  • Confirm cause is only ever set to an actual daw_error/v1

DAW/daw-lua-common#48

## Problem `fs/dir.lua`'s `remove_dir_recursive()` currently (pre-#48-fix) passes `sys:run_rc()`'s second return value as `cause` in both branches: ```lua local rc, output = sys:run_rc("rm -rf -- " .. shell_quote(path)) if rc == nil then return err("rm_failed", "rm invocation failed", { cause = output, data = { path = path } }) end ``` `sys.lua`'s `run_rc()` contract: on infrastructure failure it returns `nil, daw_error/v1` (output is a valid cause there); on a completed process with non-zero exit, it returns `rc, stdout` (output is raw process text, never a daw_error/v1, and must not be used as `cause`). Found and fixed for fs/dir.lua's own two call sites during the daw_i18n/v1 migration (DAW/daw-lua-common#48). This issue is to audit whether other run_rc()/run() callers in the library make the same mistake. ## Scope - Audit all run_rc()/run() callers for the rc==nil vs rc!=0 (or equivalent) distinction - Confirm cause is only ever set to an actual daw_error/v1 ## Related DAW/daw-lua-common#48
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DAW/daw-lua-common#56
No description provided.