[HOTFIX] Honor ENABLE_HIGHLIGHT_API_DEPLOYMENT env var on on-prem#1933
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| Filename | Overview |
|---|---|
| backend/backend/settings/base.py | Wraps env var read in CommonUtils.str_to_bool; correctly handles "true"/"false" strings, but "1" now evaluates to False (previously truthy), and neither gate site reads this setting on on-prem. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Request hits gate site] --> B{ConfigurationRegistry\nis_config_key_available?}
B -- "Yes (Cloud)" --> C[get_value_by_organization\nfor org-level override]
B -- "No (On-prem)" --> D[enable_highlight = False\nHardcoded default]
C --> E{enable_highlight?}
D --> E
E -- "False" --> F[Strip highlight_data\n& extracted_text]
E -- "True" --> G[Include highlight_data\n& extracted_text]
H[settings.ENABLE_HIGHLIGHT_API_DEPLOYMENT\nbase.py - this PR] -. not read by gate sites .-> D
style D fill:#f96,color:#000
style H fill:#ff9,color:#000
Prompt To Fix All With AI
This is a comment left during a code review.
Path: backend/backend/settings/base.py
Line: 692-694
Comment:
**`"1"` silently evaluates to `False` after this change**
`CommonUtils.str_to_bool` only returns `True` for `"true"` (case-insensitive). A user who set `ENABLE_HIGHLIGHT_API_DEPLOYMENT=1` (a common Unix convention) would have had it work before this PR (non-empty string is truthy) and silently break after it. The PR description only mentions making `"False"/"false"/"0"` falsy — `"1"` is not mentioned. Consider accepting `"1"` as truthy as well, consistent with how the similar `ConfigurationRegistry.get_value_by_organization` path parses booleans.
```suggestion
ENABLE_HIGHLIGHT_API_DEPLOYMENT = os.environ.get(
"ENABLE_HIGHLIGHT_API_DEPLOYMENT", "false"
).lower() in ("true", "1", "yes")
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (7): Last reviewed commit: "[FIX] Bool-parse ENABLE_HIGHLIGHT_API_DE..." | Re-trigger Greptile
a5e2066 to
236f94b
Compare
236f94b to
e64bc34
Compare
os.environ.get returns the raw string when the variable is set, so ENABLE_HIGHLIGHT_API_DEPLOYMENT="False" was truthy in Python (any non-empty string is truthy). Wrap in CommonUtils.str_to_bool so "False" / "false" / "0" actually evaluate to False. The setting is consumed by the cloud configuration plugin's spec default (ConfigSpec.default in plugins/configuration/cloud_config.py) on cloud and on-prem builds. With this fix, an admin who explicitly sets the env var to a falsy string sees highlight data stripped as expected. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|



Summary
v0.161.4. Pairs with cloud hotfix Zipstack/unstract-cloud#1467.ENABLE_HIGHLIGHT_API_DEPLOYMENTenv-var read inbackend/backend/settings/base.pywithCommonUtils.str_to_bool(...)so values likeFalse/false/0actually evaluate falsy. Previouslyos.environ.get(...)returned the raw string, so any non-empty value (including"False") was truthy in Python and bypassed the gate.ConfigSpec.defaultinunstract-cloud/backend/plugins/configuration/cloud_config.py.Configuration.get_value_by_organization(...)returns this default when no per-org row exists, so the bool fix takes effect on cloud and on-prem builds where the configuration plugin is loaded.Why this is the only OSS change
Test plan
ENABLE_HIGHLIGHT_API_DEPLOYMENT=true, run an API deployment (sync + polled), confirmhighlight_dataandextracted_textare present in the response metadata.ENABLE_HIGHLIGHT_API_DEPLOYMENT=False, confirm both keys are stripped (this is the case the bool fix unblocks).Configurationrow and env=true, confirm fleet-wide default keeps highlight data.False, confirm fleet-wide default strips both keys.🤖 Generated with Claude Code