Skip to content

fix(config): honor AEVS_RECEIPT_VISIBILITY env var fallback#17

Open
web3guru888 wants to merge 1 commit into
fetchai:mainfrom
web3guru888:fix/receipt-visibility-env
Open

fix(config): honor AEVS_RECEIPT_VISIBILITY env var fallback#17
web3guru888 wants to merge 1 commit into
fetchai:mainfrom
web3guru888:fix/receipt-visibility-env

Conversation

@web3guru888

Copy link
Copy Markdown

fix(config): honor AEVS_RECEIPT_VISIBILITY env var fallback

What

configure(receipt_visibility=...) defaulted to the truthy string "private",
so the resolution expression

receipt_visibility or os.environ.get("AEVS_RECEIPT_VISIBILITY", "private")

always short-circuited on the parameter and never read the
AEVS_RECEIPT_VISIBILITY environment variable. The env var was effectively
dead code.

Why it matters

The documentation states the option falls back to the env var:

  • docs/08-api-reference.md"Falls back to environment variables for api_key, agent_id, and receipt_visibility"
  • docs/06-receipt-verification.md"You can also set this via the AEVS_RECEIPT_VISIBILITY environment variable."
  • docs/03-configuration.md — lists AEVS_RECEIPT_VISIBILITY → receipt_visibility in the env-var table.

A user setting AEVS_RECEIPT_VISIBILITY=proof_only (e.g. to keep inputs/outputs
off the wire in production) silently got private instead — a privacy-relevant
surprise.

The fix

Default the parameter to None so the existing or expression resolves with
the intended precedence: explicit argument → AEVS_RECEIPT_VISIBILITY"private".

-    receipt_visibility: str = "private",
+    receipt_visibility: str | None = None,

The resolution site is unchanged — None is falsy, so precedence now works as
documented. The docstring is updated. The "never raise to host code" contract is
preserved: an invalid value from either source still warns and falls back to
"private" via _sanitize_config.

Tests

New tests/test_config.py::TestReceiptVisibility (6 cases): default,
explicit-param, env fallback, explicit-param-beats-env, case-insensitivity, and
invalid-value warn-and-fallback. The env-fallback / case / invalid cases fail on
main and pass with this change.

Verification

make check on this branch:

  • pytest: 498 passed, 2 skipped (492 baseline + 6 new)
  • ruff check: clean
  • mypy --strict: clean (22 files)

Closes the documented-vs-actual behavior gap for receipt_visibility.

The `receipt_visibility` parameter of `configure()` defaulted to the
truthy string "private", so the expression

    receipt_visibility or os.environ.get("AEVS_RECEIPT_VISIBILITY", "private")

always short-circuited on the parameter and never consulted the
environment variable. This contradicted the documented behavior
("Falls back to AEVS_RECEIPT_VISIBILITY", docs/08-api-reference.md and
docs/06-receipt-verification.md), making the env var effectively dead
code.

Default the parameter to None so resolution precedence becomes
explicit argument -> AEVS_RECEIPT_VISIBILITY -> "private". An invalid
value from either source continues to warn and fall back to "private"
via _sanitize_config (never raises to host code). Update the docstring
to document the fallback.

Adds TestReceiptVisibility regression coverage: default, explicit
param, env fallback, param-precedence-over-env, case-insensitivity,
and invalid-value warn-and-fallback.

Signed-off-by: Robin Dey <robin@vbrl.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant