Repository navigation
fix(backend): strip whitespace in bool string conversion - #14486
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
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)
|
| 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 | 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.
Comment @coderabbitai help to get the list of available commands.
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Ricky-7-Yan
left a comment
There was a problem hiding this comment.
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.
f7586f2 to
dea0c94
Compare
3c478d0
Why / What / How
Why:
convert(" true ", bool)returnsFalse— 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_boolbackend/util/type_test.py: regression asserts for" true ","1 "," false "Agents and large language models used
Checklist 📋
For code changes:
backend/util/type_test.py— 51 passedbackend/util/test_json.py(usestype_match) — 32 passedFor configuration changes:
.env.defaultis updated or already compatible with my changesdocker-compose.ymlis updated or already compatible with my changesN/A — no configuration changes.