#2277·presidio

Top-level supported_countries in the recognizer registry YAML is documented but never applied

Author: feiiiiii5Created Sep 20, 2026Updated Sep 20, 2026

Describe the bug

docs/analyzer/filtering_by_country.md documents a top-level supported_countries key for the recognizer-registry YAML and states that it is applied by the loader:

The same filter can be set globally in YAML, mirroring how supported_languages works:

yaml
supported_languages: ["en"]
supported_countries: ["us", "uk"]
recognizers:
  # ...

When the registry is built from a YAML file, this top-level supported_countries is applied automatically inside the loader; you don't need to pass countries= again from Python.

It is not. RecognizerRegistryConfig (presidio-analyzer/presidio_analyzer/input_validation/yaml_recognizer_models.py) is model_config = ConfigDict(extra="forbid") and declares only supported_languages, global_regex_flags and recognizers, so the documented file fails validation outright:

ValueError: Invalid recognizer registry configuration: ... Extra inputs are not permitted: supported_countries

and even if the key were accepted, RecognizerRegistryProvider.create_recognizer_registry() only reads supported_languages, global_regex_flags and recognizers — it never passes a country list, although RecognizerListLoader.get() already has a supported_countries: Optional[Iterable[str]] = None parameter that implements exactly this filter (it is what the Python-side countries= argument uses).

Code to reproduce

python
from presidio_analyzer.recognizer_registry import RecognizerRegistryProvider

conf = {
    "recognizer_registry": {
        "supported_languages": ["en"],
        "supported_countries": ["us"],
        "recognizers": [{"name": "US Driver License"}],
    }
}
# write conf to a file, then:
RecognizerRegistryProvider(analyzer_registry_conf_file=path).create_recognizer_registry()

Expected: a registry holding only locale-agnostic recognizers plus US ones. Actual: ValueError: Invalid recognizer registry configuration.

presidio-analyzer/presidio_analyzer/conf/default_recognizers.yaml ships the same key commented out at the top of the file, so the intended shape is visible in the repo itself.

System info

  • Presidio analyzer: current main (645dfa1c)
  • OS: macOS (arm64)
  • Python version: 3.12

Source: data-privacy-stack/presidio