Skip to content

[Bug]: an empty, unparseable or missing --policy file answers "Operation failed" without naming it #847

Closed

Description

@jimhoyd

Runtime revision and environment

Packed checkout of main a996f0d8 (0.6.5 plus #840), Node 26.10.0, macOS, local CLI. Found while building the #843 proof.

Minimal reproduction

Any project, with an operator policy file that is empty, unparseable or missing:

: > /tmp/empty-policy.json
urlcode validate --local --project app --policy /tmp/empty-policy.json
echo '{"version":1,' > /tmp/bad-policy.json
urlcode validate --local --project app --policy /tmp/bad-policy.json
urlcode validate --local --project app --policy /tmp/missing.json

In the proof this happened for real: a test wrote urlcode permissions stdout to the policy file, permissions had failed (a sandboxed route imported node:sqlite transitively), so the file was empty and the next validate said only "Operation failed".

Relevant output

{"event":"error","message":"Operation failed; check project files, module dependencies and command options"}
{"event":"error","message":"Operation failed; check project files, module dependencies and command options"}
{"event":"error","message":"Required file or directory not found"}

Expected: name the --policy file and say it is empty, not JSON, or missing, as the schema-level refusal already does ({"version":1,"projectSha256":"abc","routes":{}} answers "Policy requires version 1 and projectSha256"). Same class as #581/#714, but on the operator policy path. Not checked for serve/test/audit, which take the same flag.

Activity

  1. added
    bug
    on Sep 28, 2026
  2. jimhoyd commented on Sep 28, 2026

    @jimhoyd
    CollaboratorAuthor

    Fixed in #849: an empty, unparseable or missing policy file now names the file (policy-missing / policy-invalid). Tested in test/validation-context.test.ts.

  3. jimhoyd commented on Sep 29, 2026

    @jimhoyd
    CollaboratorAuthor

    Fixed in #849. On current main (after #899), an empty, unparseable or missing --policy file each gets a named, specific message (policy-invalid / policy-missing): "… is empty", "… is not valid JSON", "… does not exist", plus how to fix it. I re-checked all three cases today.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions