op-opsdevnz
Resolve 1Password op:// secret references at runtime so automation code
stays secret-free. Resolution uses the official 1Password Service Account SDK
for CI, with a conditional fallback to the op CLI for local development —
and a strict security posture: credential principals never switch silently,
and errors never leak secret values, fragments, or references.
Maintained by OpsDev.nz, a platform engineering collective sponsored by StartMeUp.nz.
Features
- Resolve
op://references via the official Service Account SDK with a conditional CLI fallback for local workflows. - Explicit fallback policy: the CLI is used only when the SDK path is not configured. A configured-but-failing SDK is a hard error, so resolution never silently switches credential principals.
- Sanitized errors: failure output never includes secret values, fragments,
op://references, or raw subprocess/SDK diagnostics. - Rich error handling plus an API that can return the secret value and which resolver was used.
- Environment override helpers for CI sandboxes/tests.
- Small CLI (
op-opsdevnz resolve …) that follows the same resolution semantics asresolve_secret(). Output is an opaque mask by default;--no-maskprints the resolved value.
Installation
# latest release from PyPI
pip install op-opsdevnz
# or install straight from GitHub if you need main branch changes
pip install git+https://github.com/startmeup-nz/op-opsdevnz.git
Requires Python 3.12+ and one of:
- CI / automation:
OP_SERVICE_ACCOUNT_TOKENset (a 1Password Service Account) - Workstations: the 1Password CLI
installed and signed in (
op signin)
Usage
from op_opsdevnz.onepassword import resolve_secret
result = resolve_secret(
secret_ref_env="METANAME_API_TOKEN_REF",
env_override="METANAME_API_TOKEN",
)
print(result.value, result.source) # -> ('***', 'sdk' | 'cli' | 'env')
The canonical import package is op_opsdevnz (matching the op-opsdevnz
distribution name). The legacy opsdevnz package was removed in 0.2.0.
CLI equivalent:
op-opsdevnz resolve --ref "op://Vault/Item/Field" --show-source
op-opsdevnz resolve --ref-env METANAME_API_TOKEN_REF --env-override METANAME_API_TOKEN
op-opsdevnz resolve --ref "op://Vault/Item/Field" --no-mask # print the value
Async Usage
resolve_secret() and get_secret() are synchronous and must not be called
from within a running event loop (they bridge the SDK with asyncio.run()
and raise a clear error there). Async callers use the async API directly:
from op_opsdevnz.onepassword_sdk import resolve_secret_async
value = await resolve_secret_async("op://Vault/Item/Field")
Secret Reference Files
For per-environment reference files (references only — no secret values, safe to commit):
from op_opsdevnz.env import load_refs
load_refs("staging") # loads .env.refs.staging into the environment
Fallback Policy
Resolution follows a strict rule (see docs/design/fallback-policy.md):
- Default (SDK first): with
OP_SERVICE_ACCOUNT_TOKENset, the Service Account SDK resolves the reference. Any SDK failure — authentication, authorization, resolution, rate limit — raisesSdkAuthErrorand the CLI is not tried. - Not configured: without a token (or without the SDK installed),
SdkNotConfiguredErroris raised internally and resolution falls back to the locally authenticatedopCLI. prefer_cli=True: workstations can opt into CLI-first resolution; the SDK remains the fallback so CI/service-account flows keep working.
Error classes SdkNotConfiguredError and SdkAuthError subclass
SecretError, so existing except SecretError handlers keep working.
OctoDNS integration
The Metaname-specific resolver adapter lives in the octodns-metaname module,
which uses this package for generic 1Password resolution.
Development
uv sync --extra dev
uv run ruff check src tests
uv run mypy src
uv run python -m pytest tests/ --cov
See CONTRIBUTING.md for the full workflow and RELEASING.md for publishing instructions.
License
Apache-2.0 © OpsDev.nz
Release files for op-opsdevnz 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| op_opsdevnz-0.2.1.tar.gz | 19.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| op_opsdevnz-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.2 kB
Release files / op_opsdevnz-0.2.1.tar.gz
| Download URL | op_opsdevnz-0.2.1.tar.gz |
|---|---|
| Size | 19.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ec181fbbef546f2a39a4aa856ca823d66a9c47f5560072ed5e8add091005b76b
|
|
BLAKE2b-256 checksum How to use checksums |
fa890b957c231492a72863d7edc78af4df6e7ecd3b4f0aa9f468c9585598af6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.
Transparency logRelease files / op_opsdevnz-0.2.1-py3-none-any.whl
| Download URL | op_opsdevnz-0.2.1-py3-none-any.whl |
|---|---|
| Size | 15.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ee24e453b832405a63c04fd8c671d535da447aa13cc0bbcf908b757f8450ce9d
|
|
BLAKE2b-256 checksum How to use checksums |
6ecdcec2360fcdcfe0af8a536f0ebb43c63fa0d5dfb9858767d1590170804800
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.
Transparency log