# JSON Schema validation fails: format 'uri' rejects valid URIs with IP addresses or unusual schemes

- **ID:** `data/json-schema-format-uri-referencing`
- **Domain:** data
- **Category:** validation_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

JSON Schema's built-in 'uri' format validator in some libraries (e.g., Python's jsonschema) uses strict RFC 3986 parsing that may reject valid URIs with IPv6 literals or custom schemes like 'dns://'.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| jsonschema 4.17.3 | active | — | — |
| ajv 8.12.0 | active | — | — |
| json-schema-validator 4.0.1 | active | — | — |

## Workarounds

1. **Use a custom format checker with relaxed URI validation: from jsonschema import validators; from rfc3986_validator import validate_rfc3986; def custom_uri(instance): return validate_rfc3986(instance, require_scheme=True, allow_relative=False); validator = validators.validate(..., format_checker=validators.Draft7Validator.FORMAT_CHECKER.replaces('uri', custom_uri))** (85% success)
   ```
   Use a custom format checker with relaxed URI validation: from jsonschema import validators; from rfc3986_validator import validate_rfc3986; def custom_uri(instance): return validate_rfc3986(instance, require_scheme=True, allow_relative=False); validator = validators.validate(..., format_checker=validators.Draft7Validator.FORMAT_CHECKER.replaces('uri', custom_uri))
   ```
2. **Change schema to use pattern validation instead of format: '"pattern": "^[a-zA-Z][a-zA-Z0-9+.-]*://.*$"'. This is more portable across validators.** (75% success)
   ```
   Change schema to use pattern validation instead of format: '"pattern": "^[a-zA-Z][a-zA-Z0-9+.-]*://.*$"'. This is more portable across validators.
   ```

## Dead Ends

- **** — Completely bypasses URI validation, allowing invalid URIs through and defeating the purpose of schema validation. (60% fail)
- **** — uri-reference is even more permissive and may not catch intended validation issues, plus it's not supported by all validators. (55% fail)
