Skip to content

fix(backend): strip whitespace in bool string conversion - #14486

Merged
Pwuts merged 1 commit into
Significant-Gravitas:devfrom
soroush5:fix/bool-convert-whitespace
Sep 14, 2026
Merged

Pwuts merged 1 commit into
Significant-Gravitas:devfrom
soroush5:fix/bool-convert-whitespace

Conversation

@soroush5

@soroush5 soroush5 commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Why / What / How

Why: convert(" true ", bool) returns False — the bool converter doesn't strip whitespace, so padded LLM/user input silently coerces to the wrong value and an agent can take the wrong branch. Fixes #14485.

What: One-line fix in __convert_bool (value.strip().lower()) plus regression asserts.

How: Strip before comparing against "true"/"1", matching how sibling converters already tolerate whitespace.

Changes 🏗️

  • backend/util/type.py: strip whitespace in __convert_bool
  • backend/util/type_test.py: regression asserts for " true ", "1 ", " false "

Agents and large language models used

  • None (original PR author listing; body rewritten for template compliance by Grok Bot autogpt-fix)

Checklist 📋

For code changes:

  • I have clearly listed my changes in the PR description
  • I have made a test plan
  • I have tested my changes according to the test plan:
    • backend/util/type_test.py — 51 passed
    • backend/util/test_json.py (uses type_match) — 32 passed

For configuration changes:

  • .env.default is updated or already compatible with my changes
  • docker-compose.yml is updated or already compatible with my changes
  • I have included a list of my configuration changes in the PR description (under Changes)

N/A — no configuration changes.

@soroush5
soroush5 requested a review from a team as a code owner September 10, 2026 06:55
@soroush5
soroush5 requested review from Pwuts and ntindle and removed request for a team September 10, 2026 06:55
@github-project-automation github-project-automation Bot moved this to 🆕 Needs initial review in AutoGPT development kanban Sep 10, 2026
@CLAassistant

CLAassistant commented Sep 10, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions Bot added cla: pending CLA not yet signed by all contributors platform/backend AutoGPT Platform - Back end size/s labels Sep 10, 2026
@coderabbitai

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: ab2cd15d-1296-4dff-b91f-48b0aa0310b9

📥 Commits

Reviewing files that changed from the base of the PR and between 3ce229d and f7586f2.

📒 Files selected for processing (2)
  • autogpt_platform/backend/backend/util/type.py
  • autogpt_platform/backend/backend/util/type_test.py

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (17)
  • GitHub Check: check API types
  • GitHub Check: Build, smoke, and scan (linux/arm64)
  • GitHub Check: Build, smoke, and scan (linux/amd64)
  • GitHub Check: end-to-end tests
  • GitHub Check: types
  • GitHub Check: check-docs-sync
  • GitHub Check: test (3.13)
  • GitHub Check: type-check (3.11)
  • GitHub Check: test (3.12)
  • GitHub Check: type-check (3.13)
  • GitHub Check: lint
  • GitHub Check: type-check (3.12)
  • GitHub Check: test (3.11)
  • GitHub Check: Check PR Status
  • GitHub Check: Analyze (typescript)
  • GitHub Check: conflicts
  • GitHub Check: Analyze (python)
⚠️ CI failures not shown inline (1)

Commit Status: Vercel: Vercel

Conclusion: failure

Authorization required to deploy.
🧰 Additional context used
📓 Path-based instructions (1)
Format Python code with `poetry run format`

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • autogpt_platform/backend/backend/util/type_test.py
  • autogpt_platform/backend/backend/util/type.py
🪛 Ruff (0.16.4)
autogpt_platform/backend/backend/util/type.py

[warning] 107-110: Return the condition value.strip().lower() in ["true", "1"] directly

Replace with return value.strip().lower() in ["true", "1"]

(SIM103)

🔇 Additional comments (2)
autogpt_platform/backend/backend/util/type.py (1)

107-107: LGTM!

autogpt_platform/backend/backend/util/type_test.py (1)

20-22: LGTM!


Walkthrough

The boolean string converter now trims surrounding whitespace before matching "true" or "1". Regression assertions cover padded true and false values.

Changes

Boolean conversion

Layer / File(s) Summary
Trim boolean input and validate conversions
autogpt_platform/backend/backend/util/type.py, autogpt_platform/backend/backend/util/type_test.py
__convert_bool trims string input before comparison. Tests verify padded " true ", "1 ", and " false " values.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to f7586

Whitespace-padded boolean inputs now convert as intended, with regression coverage for true, one, and false values. The change is ready to merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy issue #14485 by stripping surrounding whitespace in __convert_bool and adding regression assertions for padded true and false values.
Out of Scope Changes check ✅ Passed The changes are limited to the requested boolean conversion fix and its regression tests. No unrelated changes are present.
Description check ✅ Passed The description clearly explains the boolean conversion fix, the affected files, the regression tests, and the reason for the change.
Title check ✅ Passed The title clearly and concisely describes the main change: stripping whitespace during boolean string conversion.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.47%. Comparing base (822b2a1) to head (dea0c94).
⚠️ Report is 1 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev   #14486      +/-   ##
==========================================
- Coverage   82.49%   82.47%   -0.03%     
==========================================
  Files        3806     3806              
  Lines      283371   283371              
  Branches    25948    25948              
==========================================
- Hits       233770   233711      -59     
- Misses      43857    43911      +54     
- Partials     5744     5749       +5     
Flag Coverage Δ
platform-backend 87.20% <100.00%> (-0.02%) ⬇️
platform-frontend-e2e 27.91% <ø> (-0.24%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Platform Backend 87.20% <100.00%> (-0.02%) ⬇️
Platform Frontend 64.65% <ø> (-0.05%) ⬇️
AutoGPT Libs ∅ <ø> (∅)
Classic AutoGPT 28.43% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Ricky-7-Yan Ricky-7-Yan 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.

Reviewed the conversion path and regression scope. Trimming happens only for string inputs before the existing exact true/1 match, so the established false fallback for all other strings and native-bool behavior are unchanged. The added cases cover padded true, numeric true, and false input; backend lint, Python 3.11/3.12/3.13 tests and type checks, overlap detection, CodeQL, and container builds are green. No blocking findings.

@github-actions github-actions Bot added cla: signed CLA signed by all contributors and removed cla: pending CLA not yet signed by all contributors labels Sep 10, 2026
@ntindle
ntindle force-pushed the fix/bool-convert-whitespace branch from f7586f2 to dea0c94 Compare September 13, 2026 20:03
@Pwuts
Pwuts enabled auto-merge September 14, 2026 12:16

@Pwuts Pwuts left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@github-project-automation github-project-automation Bot moved this from 🆕 Needs initial review to 👍🏼 Mergeable in AutoGPT development kanban Sep 14, 2026
@Pwuts
Pwuts added this pull request to the merge queue Sep 14, 2026
Merged via the queue into Significant-Gravitas:dev with commit 3c478d0 Sep 14, 2026
47 of 48 checks passed
@github-project-automation github-project-automation Bot moved this from 👍🏼 Mergeable to ✅ Done in AutoGPT development kanban Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: signed CLA signed by all contributors platform/backend AutoGPT Platform - Back end size/s

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

4 participants