tobi/qmd · warning · Error

handelize: path "${path}" resulted in empty string after pro

Error message

handelize: path "${path}" resulted in empty string after processing

What it means

handelize() ran to completion but normalization/mapping of every segment produced empty strings that filtered out, leaving an empty result. This is a late safety check indicating the transformation logic itself discarded all content.

Source

Thrown at src/store.ts:2409

        const nameWithoutExt = ext ? segment.slice(0, -ext.length) : segment;

        const cleanedName = nameWithoutExt
          .replace(/[^\p{L}\p{N}$]+/gu, '-')  // Keep letters, numbers, "$"; dash-separate rest (including dots)
          .replace(/^-+|-+$/g, ''); // Remove leading/trailing dashes

        return cleanedName + ext;
      } else {
        // For directories, just clean normally
        return segment
          .replace(/[^\p{L}\p{N}$]+/gu, '-')
          .replace(/^-+|-+$/g, '');
      }
    })
    .filter(Boolean)
    .join('/');

  if (!result) {
    throw new Error(`handelize: path "${path}" resulted in empty string after processing`);
  }

  return result;
}

/**
 * Search result extends DocumentResult with score and source info
 */
export type SearchResult = DocumentResult & {
  score: number;              // Relevance score (0-1)
  source: "fts" | "vec";      // Search source (full-text or vector)
  chunkPos?: number;          // Character position of matching chunk (for vector search)
};

/**
 * Ranked result for RRF fusion (simplified, used internally)
 */
export type RankedResult = {

View on GitHub (pinned to dbfd0b4736)

Solutions

  1. Inspect the exact path in the error message and adjust the transforms or skip the file
  2. Add a fallback handle (e.g. hash of the path) when result is empty
  3. Report upstream if a legitimately valid path triggers it

Example fix

// before
return result; // throws if ''
// after
return result || `h-${createHash('sha1').update(path).digest('hex').slice(0, 12)}`;
Defensive patterns

Strategy: fallback

Validate before calling

const h = hasHandleContent(p) ? handelize(p) : hashName(p);

Try / catch

try { return handelize(p); } catch (e) { if (/empty string after processing/.test((e as Error).message)) return `h-${sha1(p).slice(0, 12)}`; throw e; }

Prevention

When it happens

Trigger: A path that passes the hasValidContent check but whose segments all become '' after the replacement pipeline (___ → /, per-segment transforms) and .filter(Boolean) removes them.

Common situations: Edge-case paths composed only of '$' route markers plus separators, or segments that the transform maps to empty; regression in segment transform rules after a code change.

Related errors


AI-assisted analysis of tobi/qmd@dbfd0b4736 (2026-08-28). Data as JSON: /api/errors/2c97df496072a775. Report an issue: GitHub.