davila7/claude-code-templates · error · Error

Invalid workflow data structure in hash

Error message

Invalid workflow data structure in hash

What it means

Structural validation after successful decode: the decoded object must contain metadata, steps, and components. If any is missing, the payload decoded fine but isn't a valid workflow, so the CLI refuses to install it.

Source

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

      // 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 || [],
        version: decodedData.version,
        hash: shortHash,
        steps: decodedData.steps,
        components: decodedData.components,
        yaml: decodedData.yaml,
        timestamp: decodedData.timestamp

View on GitHub (pinned to a0851ed10c)

Solutions

  1. Upgrade the CLI to a version matching the dashboard that produced the hash (or vice versa)
  2. Regenerate the share link so the payload includes metadata, steps, and components
  3. If building hashes programmatically, include all three required fields in the encoded JSON

Example fix

// before (payload)
{"name":"my-flow","steps":[...]}
// after (payload)
{"metadata":{...},"steps":[...],"components":[...]}
Defensive patterns

Strategy: type-guard

Validate before calling

null

Type guard

function isWorkflowData(d) {
  return d != null && typeof d === 'object'
    && 'metadata' in d && 'steps' in d && Array.isArray(d.steps)
    && 'components' in d;
}
// if generating hashes programmatically, validate before encoding:
if (!isWorkflowData(data)) throw new Error('workflow missing metadata/steps/components');

Try / catch

try {
  await installWorkflowFromHash(hash);
} catch (e) {
  if (/Invalid workflow data structure/.test(e.message)) {
    console.error('Hash decodes to an incompatible schema — regenerate with matching versions');
    process.exit(1);
  }
  throw e;
}

Prevention

When it happens

Trigger: A decodable JSON payload after the '_' that lacks one of the required keys — e.g. a hash encoding {name, steps} without metadata/components, or a payload built by a different tool/version with a different schema.

Common situations: Version skew: older hashes without the `components` field, or newer schema changes; users hand-crafting hashes from arbitrary JSON.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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