Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix: parse UNSTRUCTURED_INCLUDE_DEBUG_METADATA env var as a boolean#4399

Open
chuenchen309 wants to merge 1 commit into
Unstructured-IO:mainUnstructured-IO/unstructured:mainfrom
chuenchen309:fix/debug-metadata-env-bool-parsingchuenchen309/unstructured:fix/debug-metadata-env-bool-parsingCopy head branch name to clipboard
Open

fix: parse UNSTRUCTURED_INCLUDE_DEBUG_METADATA env var as a boolean#4399
chuenchen309 wants to merge 1 commit into
Unstructured-IO:mainUnstructured-IO/unstructured:mainfrom
chuenchen309:fix/debug-metadata-env-bool-parsingchuenchen309/unstructured:fix/debug-metadata-env-bool-parsingCopy head branch name to clipboard

Conversation

@chuenchen309

@chuenchen309 chuenchen309 commented Jul 14, 2026

Copy link
Copy Markdown

Problem

UNSTRUCTURED_INCLUDE_DEBUG_METADATA = os.getenv("UNSTRUCTURED_INCLUDE_DEBUG_METADATA", False)

os.getenv always returns a string when the variable is set, and any non-empty string is truthy in Python — so setting the variable to explicitly disable debug metadata (UNSTRUCTURED_INCLUDE_DEBUG_METADATA=false or =0) actually enables it, the opposite of the operator's intent. Only leaving the variable completely unset gives the intended False.

The codebase already has a correct helper for exactly this pattern elsewhere:

# partition/utils/config.py
def _get_bool(self, var: str, default_value: bool) -> bool:
    if value := os.environ.get(var):
        return value.lower() in ("true", "1", "t")
    return default_value

Fix

Parse the raw env var value the same way ENVConfig._get_bool does: "true"/"1"/"t" (case-insensitive) is True, everything else (including unset) is False.

Testing

Added test_include_debug_metadata_parses_bool_string, parametrized over "true"/"1"/"t" (expect True) and "false"/"0"/"no" (expect False), reloading the constants module after monkeypatch.setenv to pick up the change. Confirmed it fails against the pre-fix code (e.g. assert 'false' is False — got the string 'false', not the bool) and passes after.

AI disclosure

Developed with AI assistance (Claude Code), which located the boolean-parsing bug while auditing environment-variable handling across the codebase and noticed the existing correct pattern in ENVConfig._get_bool that this constant didn't follow. I reviewed the diff, independently reproduced the bug and the fix by executing both, and ran the tests/linters myself before opening this PR.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Shadow auto-approve: would auto-approve. Fixes a bug in boolean env var parsing that caused setting the variable to 'false' to enable debug metadata. The change is small, test-covered, and follows existing patterns.

Re-trigger cubic

os.getenv("UNSTRUCTURED_INCLUDE_DEBUG_METADATA", False) treats any
explicitly-set string as truthy in Python, so setting the variable to
"false" or "0" to explicitly disable debug metadata actually enables it
-- the opposite of the caller's intent.

Parse the value the same way ENVConfig._get_bool already does elsewhere
in this codebase: "true"/"1"/"t" (case-insensitive) is True, everything
else (including unset) is False.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@chuenchen309
chuenchen309 force-pushed the fix/debug-metadata-env-bool-parsing branch from 30a1509 to a2b0bf8 Compare July 15, 2026 22:04
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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.