Skip to main content
July 2, 2025
Question

Feature Request - Allow inject to run with missing references

  • July 2, 2025
  • 2 replies
  • 40 views

Let's assume there is a config template like `.env.template` which I want to share with my team. This could be in a git repo that is committed as part of a code base. To run all of the tests you would need all of the env vars defined but to run a subset of the tests this isn't necessary (think unit, app and int tests).

# .env.template file
# SQL - Everyone has this access
SQL_PASSWORD={{ op://User/sql/password }}
SQL_USER={{ op://User/sql/user }}

# AWS S3 - Only some people have/need to run these integration tests
# aws/password doesn't exist in this user's 1password
AWS_PASSWORD={{ op://User/aws/password }}
AWS_USER={{ op://User/aws/user }}

Now run `inject`:

op inject -i .env.template -o .env -f

[ERROR] 2025/07/02 13:38:51 could not resolve item UUID for item aws: could not find item aws in vault ...

It would be very beneficial to have a flag that ignores missing:

op inject -i .env.template -o .env -f -ignore-missing
# .env file
# SQL - Everyone has this access
SQL_PASSWORD=abcdef
SQL_USER=me

# AWS S3 - Only some people have/need to run these integration tests
# aws/password doesn't exist in this user's 1password
AWS_PASSWORD=
AWS_USER=

This would really help with 1Password adoption across my team.

2 replies

1P_SimonH
Community Manager
July 2, 2025

Hi @cfpjdds,

Thanks for contributing this! I've submitted it to our team for consideration.

ref: PB-49612756

 

cfpjddsAuthor
July 2, 2025

I gave this a bit more thought and better solution would be something like `--handle-missing` with options like `raise`, `warn`, `ignore`.

The absolution premium solution would be to have some syntax in the `.env.template` to fill with a default if the value is missing. Here `|` is used similar to how it can be used in python.

# AWS S3 - Only some people have/need to run these integration tests
# aws/password doesn't exist in this user's 1password
AWS_PASSWORD={{ op://User/aws/password | mocked_pw }}
AWS_USER={{ op://User/aws/user | }}

this would render as:

# AWS S3 - Only some people have/need to run these integration tests
# aws/password doesn't exist in this user's 1password
AWS_PASSWORD=mocked_pw
AWS_USER=

This has the nice advantage of allowing .template creators to define which missing references are allowed and which ones are not, and can input defaults that may pass their unit tests. That said, any of these solution would be a good start.

1P_SimonH
Community Manager
July 2, 2025

Hey @cfpjdds 👋

I've updated the feature request with your comment. Thank you!