From cb871f3e86485e3e0950b2de16ec257cdb6900a5 Mon Sep 17 00:00:00 2001 From: Gandalf Date: Wed, 10 Dec 2025 10:52:15 +0100 Subject: [PATCH 1/2] Fix WASM memory error in isValidAccountName Add try-catch with regex fallback when WASM isValidAccountName fails. This prevents 500 errors when WASM memory is corrupted under concurrent load. Error: WaxError: memory access out of bounds The regex fallback implements Hive account name rules but should be verified against blockchain consensus code (see TODO/003). --- apps/blog/utils/validate-links.ts | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/apps/blog/utils/validate-links.ts b/apps/blog/utils/validate-links.ts index fec5dfefc..bfc19671b 100644 --- a/apps/blog/utils/validate-links.ts +++ b/apps/blog/utils/validate-links.ts @@ -1,12 +1,39 @@ import { getChain } from '@hive/transaction/lib/chain'; +import { getLogger } from '@ui/lib/logging'; + +const logger = getLogger('validate-links'); export function isPermlinkValid(permlink: string): boolean { if (typeof permlink !== 'string') return false; return /^[a-z0-9-]{1,255}$/.test(permlink); } +/** + * Regex fallback for Hive account name validation. + * TODO: Verify against blockchain consensus code (see TODO/003-hive-username-validation.md) + */ +function isValidAccountNameFallback(name: string): boolean { + if (typeof name !== 'string') return false; + // Hive account rules: 3-16 chars, lowercase, numbers, single dots (not consecutive, not at edges) + if (name.length < 3 || name.length > 16) return false; + if (!/^[a-z]/.test(name)) return false; // must start with letter + if (!/^[a-z0-9.-]+$/.test(name)) return false; // allowed chars + if (/\.\./.test(name)) return false; // no consecutive dots + if (/^\./.test(name) || /\.$/.test(name)) return false; // no dot at edges + if (/^-/.test(name) || /-$/.test(name)) return false; // no dash at edges + return true; +} + export async function isUsernameValid(accountName: string): Promise { if (typeof accountName !== 'string') return false; - const chain = await getChain(); - return chain.isValidAccountName(accountName); + + try { + const chain = await getChain(); + return chain.isValidAccountName(accountName); + } catch (err) { + // WASM can fail with memory errors under concurrent load + // Fall back to regex validation + logger.warn(err, 'WASM isValidAccountName failed, using regex fallback'); + return isValidAccountNameFallback(accountName); + } } -- GitLab From 900ea04ef0d5e8ab5a9c2c37b71986d9f564f6d0 Mon Sep 17 00:00:00 2001 From: Gandalf Date: Wed, 10 Dec 2025 10:59:46 +0100 Subject: [PATCH 2/2] Add Git branching notes to CLAUDE.md Document that develop is the default branch (not main) and that MRs should target develop. This prevents future mistakes when creating merge requests. --- CLAUDE.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CLAUDE.md b/CLAUDE.md index 63517b861..a35d88493 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -5,6 +5,12 @@ This project uses **gitlab.syncad.com**, NOT gitlab.com. - Repository: https://gitlab.syncad.com/hive/denser - Use `glab api "projects/hive%2Fdenser/..."` for API calls +## Git Branching +- **Default branch**: `develop` (NOT `main`) +- Create feature branches from `develop` +- MRs should target `develop`, not `main` +- Example: `git checkout develop && git checkout -b fix/my-feature` + ## Package Management - Check `.gitlab-ci.yml` for current Node/pnpm versions - Example: `docker run --rm -v "$(pwd)":/app -w /app node: sh -c "corepack enable && pnpm install"` -- GitLab