From 8fa461e070c1d70452d08fe28d12904cd31f9b89 Mon Sep 17 00:00:00 2001 From: Kadir Can Ozden <101993364+bysiber@users.noreply.github.com> Date: Fri, 20 Feb 2026 15:21:39 +0300 Subject: [PATCH] Fix CLI 'get' command treating empty values as missing The 'get' command uses 'if stored_value:' to check whether a key exists. This is a truthiness check that evaluates to False for empty strings, so 'KEY=' or 'KEY=""' causes the command to exit with code 1 as if the key doesn't exist. Use 'is not None' instead to correctly distinguish between a key set to an empty string and a key that is not present. --- src/dotenv/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dotenv/cli.py b/src/dotenv/cli.py index 7a4c7adc..58c51eb3 100644 --- a/src/dotenv/cli.py +++ b/src/dotenv/cli.py @@ -136,7 +136,7 @@ def get(ctx: click.Context, key: Any) -> None: values = dotenv_values(stream=stream) stored_value = values.get(key) - if stored_value: + if stored_value is not None: click.echo(stored_value) else: sys.exit(1)