juspay/hyperswitch · error

Failed to decode master key from hex

Error message

Failed to decode master key from hex

What it means

Error "Failed to decode master key from hex" thrown in juspay/hyperswitch.

Source

Thrown at crates/router/src/services.rs:72

    config: &Settings,
    tenant: &dyn TenantConfig,
    master_config: Database,
    accounts_config: Database,
    cache_store: Arc<RedisStore>,
    test_transaction: bool,
    key_manager_state: keymanager::KeyManagerState,
) -> StorageResult<Store> {
    let database_event_emitter = Arc::clone(&key_manager_state.event_emitter);
    // Reads are served off a single replica pool regardless of tenant/accounts/global role.
    #[cfg(feature = "olap")]
    let replica_config = config.replica_database.clone().into_inner();
    #[cfg(feature = "olap")]
    let accounts_replica_config = replica_config.clone();

    #[allow(clippy::expect_used)]
    let master_enc_key = hex::decode(config.secrets.get_inner().master_enc_key.clone().expose())
        .map(StrongSecret::new)
        .expect("Failed to decode master key from hex");

    #[cfg(not(feature = "olap"))]
    let conf = (master_config.into(), accounts_config.into());
    #[cfg(feature = "olap")]
    // this would get abstracted, for all cases
    #[allow(clippy::useless_conversion)]
    let conf = (
        master_config.into(),
        replica_config.into(),
        accounts_config.into(),
        accounts_replica_config.into(),
    );

    let store: RouterStore<StoreType> = if test_transaction {
        RouterStore::test_store(
            conf,
            tenant,
            &config.redis,

View on GitHub (pinned to 806ec7dcc0)

Solutions

  1. Ensure the master key in configuration is valid hex of the expected length (32/64 bytes)

When it happens

Trigger: Thrown at crates/router/src/services.rs:71 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of juspay/hyperswitch@806ec7dcc0 (2026-08-19). Data as JSON: /api/errors/9437173a9a7fd3f9. Report an issue: GitHub.