Skip to content

Conversation

@fortmarek
Copy link
Member

Summary

  • Fix FunctionClauseError in avatar component when name contains consecutive delimiters

Problem

When a name contains consecutive delimiters (e.g., john--doe or jane__smith), String.split(~r/[\s,_\-]/) produces empty strings in the result list:

String.split("john--doe", ~r/[\s,_\-]/)
# => ["john", "", "doe"]

Then String.first("") returns nil, which causes String.upcase(nil) to fail with:

** (FunctionClauseError) no function clause matching in String.upcase/2

Solution

Filter out empty strings after splitting before processing initials:

@name
|> String.split(~r/[\s,_\-]/)
|> Enum.reject(&(&1 == ""))  # <- added
|> Enum.take(@number_of_initials)
|> Enum.map(&String.first/1)
|> Enum.map(&String.upcase/1)
|> Enum.join()

Test plan

  • Tested with names containing consecutive delimiters (e.g., test--user)
  • Verified existing avatar functionality still works

🤖 Generated with Claude Code

When a name contains consecutive delimiters (e.g., "john--doe"),
String.split produces empty strings in the result list. String.first("")
returns nil, which then causes String.upcase to fail with a
FunctionClauseError.

This fix filters out empty strings after splitting to prevent the error.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@fortmarek fortmarek requested a review from a team as a code owner January 16, 2026 16:02
@fortmarek fortmarek requested review from cschmatzler and removed request for a team January 16, 2026 16:02
@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jan 16, 2026
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 16, 2026
fortmarek added a commit to tuist/tuist that referenced this pull request Jan 16, 2026
Add a regression test for the FunctionClauseError that occurs when
rendering avatars for members whose account names contain consecutive
delimiters (e.g., "test--user").

The test is currently skipped until noora is updated to include the fix
from tuist/Noora#849

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@fortmarek fortmarek merged commit b4cdcfd into main Jan 16, 2026
6 checks passed
fortmarek added a commit to tuist/tuist that referenced this pull request Jan 16, 2026
Upgrade noora to 0.56.1 which includes a fix for the FunctionClauseError
that occurred when rendering avatars for members with consecutive
delimiters in their account names (e.g., "john--doe").

Also removes the skip tag from the regression test now that the fix is
available.

Resolves: tuist/Noora#849

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:fixed lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants