Skip to content

feat(acls): add HuJSON formatting and validation - #628

Open
KnowItAllKing wants to merge 3 commits into
tale:mainfrom
KnowItAllKing:feat/acl-hujson-format-validate
Open

feat(acls): add HuJSON formatting and validation#628
KnowItAllKing wants to merge 3 commits into
tale:mainfrom
KnowItAllKing:feat/acl-hujson-format-validate

Conversation

@KnowItAllKing

Copy link
Copy Markdown

Summary

  • add comment-preserving HuJSON formatting to the raw ACL editor
  • show live parse diagnostics and prevent invalid or empty saves
  • validate again server-side before sending policies to Headscale
  • document the editor behavior and add a Next changelog entry

Testing

  • pnpm run test:unit — 260 passed
  • pnpm run typecheck
  • pnpm run lint
  • pnpm run format
  • pnpm run build
  • manual ACL editor testing

Follow-up to #607 and #608.

@KnowItAllKing
KnowItAllKing requested a review from tale as a code owner September 3, 2026 21:04
@github-actions github-actions Bot added the Docs Improvements or additions to documentation label Sep 3, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No blocking issues — two minor observations inline.

Reviewed changes

  • Comment-preserving formatting (app/utils/acl-policy.ts) — adds formatPolicy on top of jsonc-parser's format, and rewrites parsePolicy onto parseTree with allowTrailingComma: true. The move off scanHuJson-then-JSON.parse also 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 surface validatePolicy errors 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 & changelogdocs/features/acls.md and a # Next changelog entry describe the new editor behavior.
  • Tests — unit coverage for formatPolicy, validatePolicy, the string-corruption regression, and the new action guard.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Comment thread app/utils/acl-policy.ts Outdated
Comment thread app/routes/acls/components/cm.client.tsx
… 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Empty-policy neutrality (acl-policy.ts, cm.client.tsx) — validatePolicy no longer reports an empty policy as a syntax error, and the editor shows a neutral "No policy yet" state with a CircleDashed icon instead of a red error on first run. The Format button is disabled while empty.
  • Line-preserving formatting (acl-policy.ts) — formatPolicy switched to keepLines: 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 the jsonc-parser and @codemirror/lint additions from the earlier commit.
  • Tests — updated and extended to cover keepLines layout preservation, empty-policy neutrality, and non-formatting of empty input.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Docs Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant