Skip to content

Fix IndexError in initials for unnormalized *_list elements#236

Merged
derek73 merged 1 commit into
masterfrom
fix/issue-232-initials-indexerror
Jul 5, 2026
Merged

Fix IndexError in initials for unnormalized *_list elements#236
derek73 merged 1 commit into
masterfrom
fix/issue-232-initials-indexerror

Conversation

@derek73

@derek73 derek73 commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • _process_initial split name parts with split(" "), so an element containing a doubled space (e.g. name.middle_list = ['Q R']) produced an empty-string part and part[0] raised IndexError (closes IndexError in initials_list() when a *_list attribute contains a doubled-space element #232)
  • Only direct assignment to the *_list attributes hits this — the normal constructor/property paths go through parse_pieces, which normalizes whitespace before elements reach the initials code
  • Fix is bare split(): identical to split(" ") for normalized input, never yields empty strings, and also tolerates tabs/newlines/leading/trailing whitespace; whitespace-only elements now yield no initials and are dropped by the existing caller-side filter

Test plan

  • New test written first (TDD): verified failing with the exact IndexError from the issue before the fix, asserting the doubled-space element produces the same initials as its single-space equivalent
  • Full suite: 1342 passed, 4 skipped, 22 xfailed

🤖 Generated with Claude Code

_process_initial split name parts with split(" "), which yields empty
strings for repeated spaces, and part[0] on an empty string raised
IndexError. The parse path never produces such parts because
parse_pieces normalizes whitespace, but first_list/middle_list/
last_list are plain attributes, so direct assignment bypasses that
normalization (e.g. name.middle_list = ['Q  R']).

Use bare split(), which treats any whitespace run as one delimiter and
never yields empty strings — identical to split(" ") for normalized
input, and also tolerant of tabs, newlines, and leading/trailing
whitespace in directly-assigned elements.

Closes #232

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@derek73 derek73 self-assigned this Jul 5, 2026
@derek73 derek73 added the bug label Jul 5, 2026
@derek73 derek73 added this to the v1.3.0 milestone Jul 5, 2026
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.25%. Comparing base (7b4c5fe) to head (c72953c).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #236   +/-   ##
=======================================
  Coverage   97.25%   97.25%           
=======================================
  Files          13       13           
  Lines         802      802           
=======================================
  Hits          780      780           
  Misses         22       22           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@derek73 derek73 merged commit d7ad5b6 into master Jul 5, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IndexError in initials_list() when a *_list attribute contains a doubled-space element

2 participants