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

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
cursor Bot pushed a commit to jacobyoby/docassemble that referenced this pull request Sep 9, 2026
- FORK.md: remove bool-config divergence (now upstream via PR jhpyle#983),
  add #15/#18/#19/#21/geocode-lazy to carried divergences, drop
  labelauty from CodeQL exclusions list
- TODO.md: mark PR jhpyle#983 watch as done, update version ref to 1.10.8,
  update bundle split note (labelauty removed upstream)
- codeql-config.yml: remove labelauty path exclusion (no longer used
  after upstream replaced labelauty with CSS)
jacobyoby added a commit to jacobyoby/docassemble that referenced this pull request Sep 10, 2026
) (#67)

* fix to error when a Package is deleted

* removed pdfminer.six verification code

* avoid error if playground directory does not exist

* Add accessible skip-to-main-content links

* replaced labelauty with CSS; updated screenshots; added comments; added example of acknowledging deletion of item in list; changed aria settings of div containing flash messages so that messages are announced; always add enclosing div for flash messages to the interview DOM; fix issue with session id not being set in global variable immediately after a new_session

* umask 002 for background tasks; modified bundle.sh so that the concatenation happens in the bash script, not on the server -- this cuts out a step; removed fieldset/legend and removed visually-hidden legends; changed HTML of terms and help for more accessible popovers; added feature for flashing messages that only screen readers can see; added screen reader message announcing that table item has been deleted; changed where role=group appears around radio/checkbox groups; change the way that focus is set after a page change so that focus lands on the daMainQuestion if there is no field to focus on; removed the bootstrap-fileinput plugin; altered the _edit_button and _delete_button methods so that the item is passed as a third argument, so that buttons can be customized according to the item; modified progressive disclosure recipe so that it uses details/summary; when a show if reveals additional information, screen readers are notified; altered the skip to main content link so that it uses JavaScript; updated TestContext so that it works with global variable and interview answer dictionary contexts; rebuilt screenshots

* Bump version: 1.10.7 → 1.10.8

* feat(a11y): skip link, 404 landmark + home link, print stylesheet (#18)

Skip-to-content link (WCAG 2.4.1) as the first child of <body>: in
base.html targeting #damain, and separately in the interview page
emitter (interview/views.py builds that page in Python, not from
base.html) targeting #daquestion, so it reaches the page litigants
actually use. Bootstrap's visually-hidden-focusable shows it only on
focus. The 404 page gains a <main role="main"> landmark and a link
home so a mistyped form URL no longer dead-ends. app.css gains @media
print rules dropping the navbar, its body padding, buttons, and footer;
app.min.css regenerated with clean-css.

Fail-first e2e (a11y_check.sh) asserts all three absent on the stock
release and present after install; wired into CI as control + pass.
Verified live and browser regression 7/7.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jkoq1KnMBNnfi8YQSgAAfH

* docs: post-rebase cleanup for upstream 1.10.8 sync

- FORK.md: remove bool-config divergence (now upstream via PR jhpyle#983),
  add #15/#18/#19/#21/geocode-lazy to carried divergences, drop
  labelauty from CodeQL exclusions list
- TODO.md: mark PR jhpyle#983 watch as done, update version ref to 1.10.8,
  update bundle split note (labelauty removed upstream)
- codeql-config.yml: remove labelauty path exclusion (no longer used
  after upstream replaced labelauty with CSS)

* fix(a11y): escape flash message DOM text to pass CodeQL (app.js:1752)

---------

Co-authored-by: Jonathan Pyle <jhpyle@gmail.com>
Co-authored-by: Jack Adamson <jackadamson@gmail.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Jacob Durham <jacob@jacobrakai.org>
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