ForHosting KIT · Developer Utilities

Resolve configuration value precedence

Configuration bugs often begin with a simple question that turns out to be surprisingly difficult: which value actually wins?

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

Runs in your browser. Free, unlimited — your data never leaves this page.

This capability compares values supplied by an application default, a configuration file, an environment variable, and a command-line flag, then applies the precedence order you define. It returns both the effective value and the source that supplied it, making the decision easy to inspect, test, and document. Omitted sources remain distinct from deliberately supplied empty strings, so common override behavior is represented accurately.

Describe supplied values without losing absence semantics

Put source values in the values object using the canonical names default, config_file, environment_variable, and cli_flag. A property that is not present means that source did not provide the setting. This distinction matters because an empty string may be an intentional override: for example, a CLI option might deliberately clear a prefix that exists in a file. The resolver therefore treats a present empty string as a real value and does not silently skip it. Every supplied value must be a string, which mirrors the raw form commonly read from environment variables and command-line parsers and avoids surprising coercion between zero, false, and textual values. You may also provide a setting name. It does not change selection; it is echoed in the result so logs and test fixtures remain understandable when several settings are evaluated. Unknown source names are rejected rather than ignored, helping catch spelling errors that would otherwise look like missing configuration. If none of the four properties is present, resolution fails, including when the default property is absent. That explicit error prevents a missing setting from quietly becoming an invented value.

Define and apply precedence explicitly

The precedence array lists all four sources from highest priority to lowest priority. A conventional order is CLI flag, environment variable, configuration file, then default, but the resolver does not assume that convention because applications and deployment systems differ. It examines the ordered names and selects the first source whose property exists in the values object. The returned source explains why that value won, while the returned precedence array preserves the policy used for the decision. Requiring each supported source exactly once makes the policy complete and auditable. A duplicated name, an unknown name, a missing source, or an extra entry produces an input error instead of an ambiguous partial result. This is useful when precedence rules come from documentation, framework migration work, or a test matrix: the submitted order is the entire rule, not a hint combined with hidden platform defaults. Selection is deterministic and performs no type conversion, interpolation, file access, environment lookup, or command parsing. The capability evaluates only the values you submit, so the same input always produces the same output in a browser, CI job, or API call. That makes it suitable as a small reference oracle for testing larger configuration loaders.

Use the result in tests, diagnostics, and documentation

The response contains effective_value, source, and the precedence order that was evaluated. If you supplied a setting name, the response includes it as well. This compact structure works well in unit-test fixtures: assemble the raw values observed by your loader, submit the intended policy, and assert that both the winning value and its origin match expectations. It also helps with operational diagnostics. A support tool can show that a timeout came from an environment variable rather than a checked-in file without attempting to reproduce the entire application startup process. Documentation teams can turn examples of layered settings into executable demonstrations, especially when a framework uses an unconventional order. The resolver intentionally does not read the host process environment, open configuration files, or interpret CLI syntax. Callers remain responsible for collecting those inputs and for deciding whether secrets should be submitted; sensitive credentials should generally be represented with harmless placeholders when only precedence behavior is being tested. Each request resolves one setting and costs $0.002 through the API, while the tier-A browser path uses the same pure solving logic. Because the algorithm has no network, randomness, clock, or mutable state, repeated requests with identical JSON are stable and straightforward to cache or compare.

Verify a deployment override

Confirm whether a CLI flag or environment variable wins over the value committed in a configuration file.

Build configuration loader tests

Generate clear fixtures that assert both the effective value and the source responsible for it.

Explain a surprising runtime setting

Reproduce a precedence decision from collected inputs without reading files or accessing the live environment.

Which source has the highest precedence?

The first source in the precedence array. You define the complete order for every request.

Does an empty string count as a value?

Yes. A present property with an empty string is a supplied value; an omitted property means the source supplied nothing.

Must the precedence array include every source?

Yes. It must contain each of default, config_file, environment_variable, and cli_flag exactly once.

What happens when no source provides a value?

The request returns an invalid input error. In particular, no fallback is invented when the default property is absent.

Does this read my files or process environment?

No. It only evaluates the source values included in the request and performs no network or system access.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/dev/config-precedence-resolve

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/dev/config-precedence-resolve \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"values":{"default":"development","config_file":"staging","environment_variable":"production"},"precedence":["cli_flag","environment_variable","config_file","default"]}'
{
  "values": {
    "default": "development",
    "config_file": "staging",
    "environment_variable": "production"
  },
  "precedence": [
    "cli_flag",
    "environment_variable",
    "config_file",
    "default"
  ]
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "dev.config_precedence_resolve",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the full KIT documentation →