davila7/claude-code-templates · error · Error

Failed to decode workflow data from hash

Error message

Failed to decode workflow data from hash

What it means

Final decode failure: the payload after '_' could not be decoded either as compressed data (primary path) or as legacy Base64 JSON (fallback via atob). Both attempts threw, so the hash payload is corrupt or uses an unknown encoding.

Source

Thrown at cli-tool/src/index.js:2232

      const [shortHash, encodedData] = hash.split('_', 2);
      
      if (!encodedData) {
        throw new Error('Invalid hash format: missing encoded data');
      }
      
      // Decode compressed data
      let decodedData;
      try {
        // First try to decompress the data (new compressed format)
        const decompressedString = decompressString(encodedData);
        decodedData = JSON.parse(decompressedString);
      } catch (decompressError) {
        // Fallback to old Base64 format for compatibility
        try {
          const decodedString = decodeURIComponent(escape(atob(encodedData)));
          decodedData = JSON.parse(decodedString);
        } catch (base64Error) {
          throw new Error('Failed to decode workflow data from hash');
        }
      }
      
      // Validate decoded data structure
      if (!decodedData.metadata || !decodedData.steps || !decodedData.components) {
        throw new Error('Invalid workflow data structure in hash');
      }
      
      console.log(chalk.green('✅ Workflow decoded successfully!'));
      console.log(chalk.gray(`   Short hash: ${shortHash}`));
      console.log(chalk.gray(`   Timestamp: ${decodedData.timestamp}`));
      console.log(chalk.gray(`   Version: ${decodedData.version}`));
      
      // Convert to expected format
      return {
        name: decodedData.metadata.name,
        description: decodedData.metadata.description,
        tags: decodedData.metadata.tags || [],

View on GitHub (pinned to a0851ed10c)

Solutions

  1. Update the CLI: `npx claude-code-templates@latest --workflow #hash` (newest decode formats)
  2. Regenerate the share link from the current dashboard
  3. Verify the payload wasn't altered (no URL decoding, no truncation, no regex-copied fragment)
  4. As a last resort, manually rebuild the workflow instead of using the hash
Defensive patterns

Strategy: fallback

Validate before calling

null

Try / catch

try {
  await installWorkflowFromHash(hash);
} catch (e) {
  if (/Failed to decode workflow data/.test(e.message)) {
    console.error('Unsupported/corrupt hash — update the CLI and regenerate the link');
    process.exit(1);
  }
  throw e;
}

Prevention

When it happens

Trigger: Any 'short_payload' hash where decompression throws AND atob/JSON.parse of the Base64 fallback also throws — e.g. arbitrary garbage after the underscore, or payloads encoded by a newer format the installed CLI doesn't understand.

Common situations: Version mismatch between the dashboard that generated the hash and the CLI decoding it; hash corrupted in transit; hand-edited hashes.

Understand the failure class

Related errors


AI-assisted analysis of davila7/claude-code-templates@a0851ed10c (2026-08-28). Data as JSON: /api/errors/39dd6072f9e41651. Report an issue: GitHub.