Skip to content

fix: pubkeyToHexColor returns fallback color instead of throwing on empty string#19

Open
Priyanshubhartistm wants to merge 2 commits into
ContextVM:masterfrom
Priyanshubhartistm:fix-pubkeytohexcolor-empty-string
Open

fix: pubkeyToHexColor returns fallback color instead of throwing on empty string#19
Priyanshubhartistm wants to merge 2 commits into
ContextVM:masterfrom
Priyanshubhartistm:fix-pubkeytohexcolor-empty-string

Conversation

@Priyanshubhartistm

@Priyanshubhartistm Priyanshubhartistm commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #18

pubkeyToHexColor was throwing Error('Pubkey is required') when called with an empty string. Because this function is invoked directly inside Svelte template expressions (e.g. style="background-color:{pubkeyToHexColor(pubkey)}"), the error was propagating before the pubkey prop had finished loading, crashing the component render.

Root Cause

// Before — throws during template evaluation
if (!pubkey) {
  throw new Error('Pubkey is required');
}

When validateAndDecodePubkey returns null for an invalid pubkey,
the calculateTrustScore function now sets a validationError state
instead of silently returning. The error message is displayed
below the Calculate button in red.

Fixes ContextVM#16
… empty string

pubkeyToHexColor was throwing an Error when called with an empty string,
which caused template expressions to crash before the pubkey prop had
loaded (e.g. style="background-color: {pubkeyToHexColor(pubkey)}").

Replace the throw with a return of '#888888' (neutral grey) so the
function is safe to call directly inside Svelte template expressions
during loading states.

Fixes ContextVM#18
@vercel

vercel Bot commented Jun 21, 2026

Copy link
Copy Markdown

@Priyanshubhartistm is attempting to deploy a commit to the ContextVM's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

Bug: pubkeyToHexColor throws on empty string, crashing template rendering

1 participant