Detect plain-string error propagation in DAW 2.x Lua code #134

Open
opened 2026-08-14 17:32:45 +02:00 by michael · 1 comment
Owner

Problem

The DAW 2.x error model requires structured daw_error/v1 objects at
the point where actual errors are detected. Historically, internal
helpers could return plain error strings, and that pattern can reappear
unless checked mechanically.

Goal

Teach Fragjan to detect likely plain-string error propagation in DAW 2.x
Lua error paths.

Initial checks

Flag likely cases such as:

return nil, "error text"
return nil, err_string

when they represent actual error propagation, including cases where a
plain helper error is later passed as the complete message of a
daw_error/v1.

Do not assume every returned string is an error.

Acceptance criteria

  • Plain-string propagation in DAW 2.x error paths can be detected.
  • Internal/local helpers are checked as well as public functions.
  • Ordinary non-error string returns are not treated as violations.
  • Fixture: internal helper returning plain error string.
  • Fixture: internal helper returning daw_error/v1.
  • Fixture: higher-level error preserving the lower-level one via cause.
  • Documentation explains the rule and remediation.
  • The check runs through normal fragjan code ..
  • DAW/daw-lua-common#48
  • daw_error/v1
## Problem The DAW 2.x error model requires structured `daw_error/v1` objects at the point where actual errors are detected. Historically, internal helpers could return plain error strings, and that pattern can reappear unless checked mechanically. ## Goal Teach Fragjan to detect likely plain-string error propagation in DAW 2.x Lua error paths. ## Initial checks Flag likely cases such as: ```lua return nil, "error text" return nil, err_string ``` when they represent actual error propagation, including cases where a plain helper error is later passed as the complete message of a `daw_error/v1`. Do not assume every returned string is an error. ## Acceptance criteria - [ ] Plain-string propagation in DAW 2.x error paths can be detected. - [ ] Internal/local helpers are checked as well as public functions. - [ ] Ordinary non-error string returns are not treated as violations. - [ ] Fixture: internal helper returning plain error string. - [ ] Fixture: internal helper returning `daw_error/v1`. - [ ] Fixture: higher-level error preserving the lower-level one via `cause`. - [ ] Documentation explains the rule and remediation. - [ ] The check runs through normal `fragjan code .`. ## Related - `DAW/daw-lua-common#48` - `daw_error/v1`
Author
Owner

Known limitation: no-plain-string-error-variable

no-plain-string-error-variable stays at warning level as long as it
is implemented via linepattern. It intentionally flags ambiguous
return nil, <identifier> sites for human review.

Correct propagation of an identifier that already holds a
daw_error/v1 object cannot be distinguished reliably by linepattern
alone -- it has no notion of a variable's origin or type, only the
text of the current line.

Type-/flow-aware suppression of these false positives depends on the
Lua structural analysis tracked in DAW/fragjan#107 (luascan).

Until then, known-correct sites may be explicitly suppressed after
human review. They are not violations merely because the warning
remains -- the warning marks "needs a human look", not "is wrong".

## Known limitation: no-plain-string-error-variable `no-plain-string-error-variable` stays at warning level as long as it is implemented via `linepattern`. It intentionally flags ambiguous `return nil, <identifier>` sites for human review. Correct propagation of an identifier that already holds a `daw_error/v1` object cannot be distinguished reliably by linepattern alone -- it has no notion of a variable's origin or type, only the text of the current line. Type-/flow-aware suppression of these false positives depends on the Lua structural analysis tracked in `DAW/fragjan#107` (luascan). Until then, known-correct sites may be explicitly suppressed after human review. They are not violations merely because the warning remains -- the warning marks "needs a human look", not "is wrong".
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/fragjan#134
No description provided.