deepinsight/insightface · error · std::out_of_range

out_of_range in Parameter::get :

Error message

out_of_range in Parameter::get : 

What it means

Parameter::get<ValueType>(name) looks up a key in the configuration map and throws std::out_of_range including the key name when has(name) is false. This is the library's standard way of saying a required configuration/manifest key is missing — the message suffix tells you exactly which key was requested. It propagates up through callers such as next, get_image_feature, and extract_feats_labels, which read pipeline configuration keys at runtime.

Source

Thrown at cpp-package/inspireface/cpp/inspireface/middleware/configurable.h:77

    /**
     * @brief Set a parameter with a specific name and value.
     * @param name The name of the parameter.
     * @param value The value to set for the parameter.
     */
    template <typename ValueType>
    void set(const std::string& name, const ValueType& value) {
        m_configuration[name] = value;
    }

    /**
     * @brief Set a parameter with a specific name and value.
     * @param name The name of the parameter.
     * @param value The value to set for the parameter.
     */
    template <typename ValueType>
    ValueType get(const std::string& name) const {
        if (!has(name)) {
            throw std::out_of_range("out_of_range in Parameter::get : " + name);
        }
        return m_configuration.at(name).get<ValueType>();
    }

    /**
     * @brief Load parameters from a JSON object.
     * @param j The JSON object containing parameters.
     */
    void load(const nlohmann::json& j) {
        for (const auto& item : j.items()) {
            const auto& key = item.key();
            const auto& value = item.value();

            if (value.is_boolean()) {
                set<bool>(key, value.get<bool>());
            } else if (value.is_number_integer()) {
                set<int>(key, value.get<int>());
            } else if (value.is_number_float()) {

View on GitHub (pinned to 7fadd420c2)

Solutions

  1. Note the key name in the exception message and inspect the loaded pack's JSON configuration to confirm whether that key exists.
  2. Ensure the resource pack / model bundle version matches the InspireFace library version — regenerate or download the matching pack.
  3. If building the config yourself, add the missing key with a valid value per the schema used by the calling code path.
  4. Guard reads with has(name) or get-or-default accessors for optional parameters instead of blind get().

Example fix

// before
int threads = param.get<int>("feature_extract_threads"); // throws out_of_range if key missing
// after
int threads = param.has("feature_extract_threads")
    ? param.get<int>("feature_extract_threads")
    : 4; // sensible default
Defensive patterns

Strategy: try-catch

Validate before calling

// Parameter exposes has(name) — check before get
if (param.has("feature_extract_threads")) {
    threads = param.get<int>("feature_extract_threads");
} else {
    threads = 4; // default
}

Try / catch

try {
    auto v = param.get<int>(key);
} catch (const std::out_of_range& e) {
    // e.what() contains the missing key name; log and apply default
}

Prevention

When it happens

Trigger: Loading a session/resource pack whose JSON configuration is missing a key that the running code path expects (e.g. feature extraction parameters when calling get_image_feature/extract_feats_labels); passing a custom or hand-edited resource pack with renamed/omitted fields; version mismatch where a newer binary expects config keys absent from an older .bundle/pack file; a typo in the key name passed to get().

Common situations: Upgrading the InspireFace native library without regenerating/upgrading the resource pack so new config keys don't exist; using a stripped-down model pack for a feature (e.g. face feature extraction) whose section isn't in the JSON; swapping contexts between detection-only and full pipelines while the loaded configuration only contains the detection section.

Related errors


AI-assisted analysis of deepinsight/insightface@7fadd420c2 (2026-08-28). Data as JSON: /api/errors/9f2f1ec28d8d354b. Report an issue: GitHub.