jdx/mise · error

invalid remote task cache key

Error message

invalid remote task cache key

What it means

validate_remote_key requires a remote task cache key to be exactly 64 characters of lowercase hex (a sha256-style digest). Any key that differs in length or contains characters outside [0-9a-f] is rejected, since keys are content digests by construction.

Solutions

  1. Compute the key as the lowercase hex sha256 digest of the cache inputs, and pass that exact string.
  2. Normalize the key before use: lowercase it and strip prefixes/whitespace.
  3. Check for truncation — a 32-char key is a half-written md5-style digest, not the required 64-char sha256 hex.
  4. If a custom producer writes keys, switch it to the same 64-hex digest scheme mise uses.

Example fix

// before
let key = format!("sha256:{:x}", digest); // prefixed, wrong format
// after
let key = hex::encode(Sha256::digest(inputs)); // 64 lowercase hex chars
Defensive patterns

Strategy: validation

Validate before calling

const isValidKey = k => /^[0-9a-f]{64}$/.test(k);
if (!isValidKey(key)) throw new Error('key must be 64 lowercase hex chars');

Type guard

const isHex64 = (k) => typeof k === 'string' && /^[0-9a-f]{64}$/.test(k);

Prevention

When it happens

Trigger: Calling the remote cache store (commit/get) with a key string that is not exactly 64 lowercase hex characters — e.g. an uppercase hash, a truncated hash, a prefixed key like "sha256:...", or a human-readable cache name.

Common situations: Custom cache-server integrations that generate their own key format; configuration pointing cache operations at user-supplied identifiers instead of computed digests; keys copied with surrounding whitespace or wrong casing.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/52136fa4e88eac4c. Report an issue: GitHub.

Appendix: source

Thrown at src/task/task_cache_store.rs:840

            }
            RestoredNode::Symlink { target, .. } => {
                header.set_size(0);
                archive.append_link(&mut header, path, target)?;
            }
        }
    }
    let encoder = archive.into_inner()?;
    encoder.finish()?;
    Ok(archive_file)
}

fn validate_remote_key(key: &str) -> Result<()> {
    if key.len() != 64
        || !key
            .bytes()
            .all(|byte| byte.is_ascii_digit() || (b'a'..=b'f').contains(&byte))
    {
        bail!("invalid remote task cache key");
    }
    Ok(())
}

pub(crate) struct LocalTaskCacheStore {
    root: PathBuf,
}

impl LocalTaskCacheStore {
    pub(crate) fn new(root: PathBuf) -> Self {
        Self { root }
    }

    fn paths(&self, key: &str) -> (PathBuf, PathBuf) {
        (
            self.root.join(format!("{key}.tar.zst")),
            self.root.join(format!("{key}.json")),
        )

View on GitHub (pinned to 533346cc37)