fix(hooks): validate statusLine against schema, not truthy#209
Open
d123d wants to merge 1 commit intoJuliusBrussee:mainfrom
Open
fix(hooks): validate statusLine against schema, not truthy#209d123d wants to merge 1 commit intoJuliusBrussee:mainfrom
d123d wants to merge 1 commit intoJuliusBrussee:mainfrom
Conversation
Before: 'if (settings.statusLine)' accepts any truthy value — strings like 'todo', numbers, arrays, malformed objects, partial shapes. All of those suppress the statusline setup nudge even though no working statusline is configured. After: check against the real schema that settings.json expects: - settings.statusLine.type === 'command' - settings.statusLine.command is a non-empty string Happy path unchanged (a correctly-configured statusLine still skips the nudge). Edge cases that were silently suppressing the nudge now correctly trigger it. node --check passes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
`hooks/caveman-activate.js:118`:
```js
if (settings.statusLine) {
hasStatusline = true;
}
```
Plain truthy check. Passes on any non-falsy value — strings (`"todo"`, `"true"`), numbers, arrays, partial objects (e.g. `{"type": "command"}` with no `command`), malformed shapes.
Consequence: user edits `settings.json`, types something wrong, the statusline doesn't actually work, but the nudge is suppressed — so the user gets no feedback about why their badge is broken.
Fix
Validate against the real schema:
```js
const sl = settings && settings.statusLine;
if (sl && sl.type === 'command' && typeof sl.command === 'string' && sl.command.length > 0) {
hasStatusline = true;
}
```
Backward compat
Correctly-configured `statusLine` still passes (unchanged behavior). Malformed/partial `statusLine` now correctly triggers the setup nudge.
Verify
```
node --check hooks/caveman-activate.js
```
Passes.