Skip to content

vault.get() regex does not support spaces in vault names or secret keys #902

@danmcclain

Description

@danmcclain

Description

The vault.get() regex in src/domain/expressions/model_resolver.ts does not support spaces in vault names or secret keys, even when quoted.

Steps to Reproduce

  1. Create a vault backed by 1Password: swamp vault create @swamp/1password infra --config '{"op_vault": "Infra"}'
  2. The 1Password item has fields with spaces, e.g. Client ID and Client Secret
  3. Use a vault expression in a workflow: ${{ vault.get(infra, Tailscale K8s Operator/Client ID) }}
  4. Run the workflow

Expected: The vault expression resolves the secret value.

Actual: CEL parse error: Expected RPAREN, got IDENTIFIER — the space in the key breaks parsing before the vault regex even runs.

Even if the CEL layer is bypassed, the vault regex itself would fail:

const vaultPattern = /vault\.get\(\s*(['"\`]?)([^'"\`\s,]+)\1\s*,\s*(['"\`]?)([^'"\`\s,]+)\3\s*\)/g;

The capture group [^'"\\s,]+explicitly excludes whitespace, soTailscale K8s Operator/Client ID` stops matching at the first space.

Workaround

Rename the 1Password fields to remove spaces (e.g. ClientID instead of Client ID), or use the item UUID with spaceless field names.

Suggested Fix

Update the vault regex to allow spaces inside quoted arguments. When quotes are present, the inner capture should permit any character except the matching quote. For example:

/vault\.get\(\s*(?:(['"\`])(.+?)\1|([^\s,)]+))\s*,\s*(?:(['"\`])(.+?)\4|([^\s,)]+))\s*\)/g

This would allow both vault.get(infra, mykey) and vault.get("infra", "My Key With Spaces").

The CEL expression parser layer (${{ }}) would also need to handle the vault.get() call before passing to the CEL evaluator, since CEL itself tokenizes on spaces.

Environment

  • swamp version: 20260327.235335.0-sha.0c993a65
  • OS: macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglifecycle/doneCompleted and merged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions