Skip to content

Handle empty or whitespace-only dispute answer titles consistently #2564

Description

@coderabbitai

Summary

Disputes created by interacting with the contracts directly can contain answers whose title is empty or whitespace-only. The embedded resolver prevents an exactly empty title during normal creation, but presentation code must still handle externally supplied dispute data defensively.

Define and apply a consistent fallback for empty/whitespace-only answer titles (for example, a localized Unknown Option label or the existing Answer 0x{{ruling}} form). Decide whether the normalization belongs in kleros-sdk's dispute-data mapping or in a shared web presentation helper; do not add an isolated workaround only to the vote-confirmation modal.

Search findings

web rendering paths

  • web/src/pages/Cases/CaseDetails/Voting/OptionsContainer.tsx renders answer.title on voting buttons and derives the confirmation-modal choice from the title.
  • web/src/pages/Cases/CaseDetails/Voting/ConfirmVoteModal.tsx renders the selected choice.
  • web/src/components/DisputePreview/DisputeContext.tsx renders each answer title.
  • web/src/components/Verdict/Answer.tsx renders the current answer title.
  • web/src/pages/Cases/CaseDetails/Appeal/Classic/Options/StageTwo.tsx renders choice.title.
  • web/src/utils/getVoteChoice.ts returns selectedAnswer.title whenever an answer exists; it currently does not fall back for an empty title. Its callers include voting detail views.
  • web/src/pages/Profile/Votes/VoteCard/index.tsx has a partial falsy-title fallback today.

kleros-sdk

  • kleros-sdk/src/dataMappings/retrieveRealityData.ts produces answer objects. The search found this mapping layer but no SDK UI renderer.

Existing creation validation

  • web/src/pages/Resolver/NavigationButtons/NextButton.tsx and web/src/pages/Resolver/NavigationButtons/SubmitDisputeButton.tsx reject exactly empty titles in the resolver flow. This does not protect consumers of data from direct contract interactions, and it does not reject whitespace-only titles.

Acceptance criteria

  • Choose and document one fallback/normalization contract for answer titles that are empty or whitespace-only.
  • Apply it consistently to all affected web display paths, including voting buttons, the confirmation modal, dispute preview, verdict, appeal, vote details, and profile vote cards.
  • Evaluate whether kleros-sdk should normalize at kleros-sdk/src/dataMappings/retrieveRealityData.ts or preserve raw data and expose a reusable helper/contract to consumers.
  • Add translations if the chosen fallback requires them.
  • Add focused tests covering "" and whitespace-only titles, including the selected choice shown during voting.
  • Ensure a stable non-title React key is used wherever an empty or duplicate title could be a list key.

Backlinks

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions