Skip to content

Fix AttributeError when 'main page title url opens in other window' is boolean - #983

Closed
jacobyoby wants to merge 1 commit into
jhpyle:masterfrom
jacobyoby:fix/issue-980-bool-strip-attributeerror
Closed

Fix AttributeError when 'main page title url opens in other window' is boolean#983
jacobyoby wants to merge 1 commit into
jhpyle:masterfrom
jacobyoby:fix/issue-980-bool-strip-attributeerror

Conversation

@jacobyoby

Copy link
Copy Markdown

Summary

Fixes #980

When main page title url opens in other window is set to a YAML boolean (False or True) in the configuration, docassemble crashes with:

AttributeError: 'bool' object has no attribute 'strip'

The workaround was to quote the value as a string ("False"), but booleans should work since YAML naturally parses unquoted False/True as booleans.

Root cause

In docassemble_base/docassemble/base/parse.py, the default_title initialization loop processes main page * config values and calls .strip() directly on the value without converting to string first:

# Before (line 8450-8451):
if parts.get('main page ' + title_name, '') != '':
    self.default_title[lang][title_abb] = parts['main page ' + title_name].strip()

False != '' evaluates to True, so the code enters the block and calls False.strip() → crash.

Fix

Wrap with str() before .strip(), matching the pattern already used on lines 8441 and 8443 in the same loop for metadata values:

# After:
if str(parts.get('main page ' + title_name, '')).strip() != '':
    self.default_title[lang][title_abb] = str(parts['main page ' + title_name]).strip()

The downstream consumer in helpers.py:1207 already compares via str(status.title_url_opens_in_other_window) == 'False', so the string representation flows through correctly.

Verified behavior

Input Result
False (bool) "False" → title opens in same window ✓
True (bool) "True" → title opens in new window ✓
"False" (string, existing workaround) "False" → same window ✓
"" (empty string) Skipped (no default set) ✓
Missing key Skipped ✓

…boolean

When `main page title url opens in other window` is set to a YAML
boolean (e.g. `False`), the default_title initialization in
Interview.__init__ called `.strip()` on the bool value, raising
`AttributeError: 'bool' object has no attribute 'strip'`.

Wrap the value with `str()` before `.strip()`, consistent with how
the same loop already handles metadata values on the lines above
(lines 8441, 8443). The downstream consumer in helpers.py already
compares via `str(status.title_url_opens_in_other_window) == 'False'`,
so the string representation flows through correctly.

Fixes jhpyle#980
@jacobyoby
jacobyoby marked this pull request as draft September 1, 2026 17:59
@jacobyoby jacobyoby closed this Sep 2, 2026
@jacobyoby
jacobyoby deleted the fix/issue-980-bool-strip-attributeerror branch September 2, 2026 01:51
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.

main page title url opens in other window: False causes AttributeError

2 participants