Homebrew formula parser throws on valid non-object JSON
- Dominant language
- TypeScript
- Stars
- 22.5k
- Forks
- 3.1k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 715
Description
## Investigation Summary
- Current `origin/main` at `5b14e5c299c3779c77895a6c092e874770551a18` reproduces the failure.
- A successful `brew info --json=v2 openshell` operation that returns valid JSON `null` causes an untyped `TypeError`.
- Invalid JSON already becomes `OpenShellGatewayServiceTrustError`, but valid JSON with the wrong shape bypasses that boundary.
- Open issues and PRs contain no matching report or fix.
## Description
The macOS Homebrew service resolver assumes that parsed JSON is a non-null object before it reads `formulae`. If the trusted operation returns valid JSON with another shape, service detection throws an internal `TypeError`.
NemoClaw should reject malformed Homebrew formula data with `OpenShellGatewayServiceTrustError` and a stable diagnostic.
## Reproduction Steps
1. Build the plugin with `npm --prefix nemoclaw run build`.
2. Call `hasOpenShellGatewayUserService` with `platform: "darwin"` and `commandExists: () => true`.
3. Provide `homebrewFormulaOperation: () => ({ status: 0, stdout: "null", stderr: "" })`.
4. Observe the untyped property-access error.
## Environment
- OS: macOS
- Node.js: v24.16.0
- NemoClaw: `origin/main` at `5b14e5c299c3779c77895a6c092e874770551a18`
- Docker: Not required for this in-process reproduction
## Debug Output
This failure occurs before a live gateway or Docker operation. The injected trusted-operation result is `{ status: 0, stdout: "null", stderr: "" }`.
## Logs
```shell
TypeError: Cannot read properties of null (reading 'formulae')
```
## Checklist
- [x] I confirmed this bug is reproducible
- [x] I searched existing issues and this is not a duplicate
Contributor guide
Research direction
Locate hasOpenShellGatewayUserService and the Homebrew formula parsing path, then build the plugin with npm --prefix nemoclaw run build and reproduce the injected stdout of "null". Add or update the relevant tests so valid non-object JSON produces OpenShellGatewayServiceTrustError with a stable diagnostic instead of TypeError; done means the macOS resolver handles malformed formula data consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100