Repository navigation
feat(acls): add HuJSON formatting and validation - #628
Merged
Merged
Conversation
There was a problem hiding this comment.
ℹ️ No blocking issues — two minor observations inline.
Reviewed changes
- Comment-preserving formatting (
app/utils/acl-policy.ts) — addsformatPolicyon top ofjsonc-parser'sformat, and rewritesparsePolicyontoparseTreewithallowTrailingComma: true. The move offscanHuJson-then-JSON.parsealso fixes a latent bug where the trailing-comma regex corrupted,}/,]sequences inside string values. - Live diagnostics (
cm.client.tsx) — a CodeMirror linter plus a status bar surfacevalidatePolicyerrors inline, and a Format button reflows the buffer. - Save gating (
overview.tsx,acl-action.ts) — the Save button disables on empty or invalid policy, and the action re-validates server-side before forwarding to Headscale. - Docs & changelog —
docs/features/acls.mdand a# Nextchangelog entry describe the new editor behavior. - Tests — unit coverage for
formatPolicy,validatePolicy, the string-corruption regression, and the new action guard.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Empty-policy neutrality (
acl-policy.ts,cm.client.tsx) —validatePolicyno longer reports an empty policy as a syntax error, and the editor shows a neutral "No policy yet" state with aCircleDashedicon instead of a red error on first run. The Format button is disabled while empty. - Line-preserving formatting (
acl-policy.ts) —formatPolicyswitched tokeepLines: true, so blank-line section groupings and inline arrays survive formatting while indentation and spacing are still normalized. - Nix hash bump (
nix/package.nix) — the dependency hash now matches thejsonc-parserand@codemirror/lintadditions from the earlier commit. - Tests — updated and extended to cover
keepLineslayout preservation, empty-policy neutrality, and non-formatting of empty input.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
… as neutral Formatting now keeps existing line breaks so blank-line groupings and inline arrays in hand-written policies survive. An empty policy is no longer reported as a syntax error; the editor shows a neutral "No policy yet" state instead.
tale
force-pushed
the
feat/acl-hujson-format-validate
branch
from
October 28, 2026 21:23
5a910af to
42ef623
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Validation consolidated on
parsePolicy(app/utils/acl-policy.ts,app/routes/acls/acl-action.ts,app/routes/acls/components/cm.client.tsx) —validatePolicyis removed;parsePolicynow carriesdiagnosticson failure, and the editor status bar, the linter and the save action all read from the one parse. trimBracketPaddingadded (app/utils/acl-policy.ts) — post-processes the formatter output so single-line arrays render as["a"]instead of[ "a" ]. Strings, comments and multi-line arrays are left untouched (verified against thejsonc-parserscanner andapplyEditsbehavior).- Humanized parse errors read more naturally — subsequent words are lowercased (
Value Expected→Value expected) while theat line X, column Ysuffix is kept. - Test cleanup — the now-redundant
validatePolicycases and the isolatedacl-actionunit test are dropped; the invalid-policy path stays covered bytests/integration/headplane/acls.test.ts.
Both prior findings from the initial review were already addressed and their threads resolved. typecheck, lint and pnpm test:unit (253 tests) pass at 42ef623.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
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.

Summary
Testing
Follow-up to #607 and #608.