|
| 1 | +# Schema Validation Gaps Report |
| 2 | + |
| 3 | +## Summary |
| 4 | + |
| 5 | +Multiple AdCP JSON schemas document "mutually exclusive" field constraints in descriptions but **do not enforce them** through JSON Schema validation. This allows invalid data to pass schema validation. |
| 6 | + |
| 7 | +## Impact |
| 8 | + |
| 9 | +- **Validation fails silently** - invalid data passes schema checks |
| 10 | +- **Runtime errors downstream** - applications must handle ambiguous data |
| 11 | +- **Inconsistent implementations** - different clients may interpret differently |
| 12 | +- **Poor DX** - validation errors caught late in development |
| 13 | + |
| 14 | +## Issues Found |
| 15 | + |
| 16 | +### 1. Product Schema: `publisher_properties` Items |
| 17 | + |
| 18 | +**File**: `/schemas/v1/core/product.json` (lines 126-162) |
| 19 | + |
| 20 | +**Problem**: The `property_ids` and `property_tags` fields are documented as mutually exclusive but both can be provided (or neither). |
| 21 | + |
| 22 | +**Current Schema** (lines 130-158): |
| 23 | +```json |
| 24 | +{ |
| 25 | + "publisher_properties": { |
| 26 | + "items": { |
| 27 | + "properties": { |
| 28 | + "property_ids": { |
| 29 | + "description": "Specific property IDs from the publisher's adagents.json. Mutually exclusive with property_tags.", |
| 30 | + ... |
| 31 | + }, |
| 32 | + "property_tags": { |
| 33 | + "description": "Property tags from the publisher's adagents.json. Product covers all properties with these tags. Mutually exclusive with property_ids.", |
| 34 | + ... |
| 35 | + }, |
| 36 | + "publisher_domain": { ... } |
| 37 | + }, |
| 38 | + "required": ["publisher_domain"], |
| 39 | + "type": "object" |
| 40 | + } |
| 41 | + } |
| 42 | +} |
| 43 | +``` |
| 44 | + |
| 45 | +**Required Fix**: |
| 46 | +```json |
| 47 | +{ |
| 48 | + "publisher_properties": { |
| 49 | + "items": { |
| 50 | + "properties": { ... }, |
| 51 | + "required": ["publisher_domain"], |
| 52 | + "oneOf": [ |
| 53 | + { |
| 54 | + "required": ["property_ids"], |
| 55 | + "not": { "required": ["property_tags"] } |
| 56 | + }, |
| 57 | + { |
| 58 | + "required": ["property_tags"], |
| 59 | + "not": { "required": ["property_ids"] } |
| 60 | + } |
| 61 | + ], |
| 62 | + "additionalProperties": false, |
| 63 | + "type": "object" |
| 64 | + } |
| 65 | + } |
| 66 | +} |
| 67 | +``` |
| 68 | + |
| 69 | +### 2. AdAgents Schema: Agent Authorization Fields |
| 70 | + |
| 71 | +**File**: `/schemas/v1/adagents.json` (lines 200-279) |
| 72 | + |
| 73 | +**Problem**: The agent authorization has **four** mutually exclusive fields (`properties`, `property_ids`, `property_tags`, `publisher_properties`) but no validation enforcing this. |
| 74 | + |
| 75 | +**Current Schema** (lines 207-269): |
| 76 | +```json |
| 77 | +{ |
| 78 | + "properties": { |
| 79 | + "properties": { |
| 80 | + "description": "Specific properties this agent is authorized for (alternative to property_ids/property_tags). Mutually exclusive with property_ids and property_tags fields.", |
| 81 | + ... |
| 82 | + }, |
| 83 | + "property_ids": { |
| 84 | + "description": "Property IDs this agent is authorized for. Resolved against the top-level properties array in this file. Mutually exclusive with property_tags and properties fields.", |
| 85 | + ... |
| 86 | + }, |
| 87 | + "property_tags": { |
| 88 | + "description": "Tags identifying which properties this agent is authorized for. Resolved against the top-level properties array in this file using tag matching. Mutually exclusive with property_ids and properties fields.", |
| 89 | + ... |
| 90 | + }, |
| 91 | + "publisher_properties": { |
| 92 | + "description": "Properties from other publisher domains this agent is authorized for. Each entry specifies a publisher domain and which of their properties this agent can sell (by property_id or property_tags). Mutually exclusive with property_ids, property_tags, and properties fields.", |
| 93 | + ... |
| 94 | + } |
| 95 | + }, |
| 96 | + "required": ["url", "authorized_for"] |
| 97 | +} |
| 98 | +``` |
| 99 | + |
| 100 | +**Required Fix**: |
| 101 | +```json |
| 102 | +{ |
| 103 | + "properties": { ... }, |
| 104 | + "required": ["url", "authorized_for"], |
| 105 | + "oneOf": [ |
| 106 | + { |
| 107 | + "required": ["properties"], |
| 108 | + "not": { |
| 109 | + "anyOf": [ |
| 110 | + { "required": ["property_ids"] }, |
| 111 | + { "required": ["property_tags"] }, |
| 112 | + { "required": ["publisher_properties"] } |
| 113 | + ] |
| 114 | + } |
| 115 | + }, |
| 116 | + { |
| 117 | + "required": ["property_ids"], |
| 118 | + "not": { |
| 119 | + "anyOf": [ |
| 120 | + { "required": ["properties"] }, |
| 121 | + { "required": ["property_tags"] }, |
| 122 | + { "required": ["publisher_properties"] } |
| 123 | + ] |
| 124 | + } |
| 125 | + }, |
| 126 | + { |
| 127 | + "required": ["property_tags"], |
| 128 | + "not": { |
| 129 | + "anyOf": [ |
| 130 | + { "required": ["properties"] }, |
| 131 | + { "required": ["property_ids"] }, |
| 132 | + { "required": ["publisher_properties"] } |
| 133 | + ] |
| 134 | + } |
| 135 | + }, |
| 136 | + { |
| 137 | + "required": ["publisher_properties"], |
| 138 | + "not": { |
| 139 | + "anyOf": [ |
| 140 | + { "required": ["properties"] }, |
| 141 | + { "required": ["property_ids"] }, |
| 142 | + { "required": ["property_tags"] } |
| 143 | + ] |
| 144 | + } |
| 145 | + } |
| 146 | + ] |
| 147 | +} |
| 148 | +``` |
| 149 | + |
| 150 | +### 3. AdAgents Schema: `publisher_properties` Items |
| 151 | + |
| 152 | +**File**: `/schemas/v1/adagents.json` (lines 233-269) |
| 153 | + |
| 154 | +**Problem**: Within `publisher_properties` array items, `property_ids` and `property_tags` are mutually exclusive but not validated (same as Product schema issue #1). |
| 155 | + |
| 156 | +**Current Schema** (lines 237-265): |
| 157 | +```json |
| 158 | +{ |
| 159 | + "publisher_properties": { |
| 160 | + "items": { |
| 161 | + "properties": { |
| 162 | + "property_ids": { |
| 163 | + "description": "Specific property IDs from the publisher's adagents.json properties array. Mutually exclusive with property_tags.", |
| 164 | + ... |
| 165 | + }, |
| 166 | + "property_tags": { |
| 167 | + "description": "Property tags from the publisher's adagents.json tags. Agent is authorized for all properties with these tags. Mutually exclusive with property_ids.", |
| 168 | + ... |
| 169 | + }, |
| 170 | + "publisher_domain": { ... } |
| 171 | + }, |
| 172 | + "required": ["publisher_domain"], |
| 173 | + "additionalProperties": false, |
| 174 | + "type": "object" |
| 175 | + } |
| 176 | + } |
| 177 | +} |
| 178 | +``` |
| 179 | + |
| 180 | +**Required Fix**: Same as Product schema fix (add `oneOf` constraint). |
| 181 | + |
| 182 | +## Recommended Actions |
| 183 | + |
| 184 | +1. **Report to upstream** - File issue with adcontextprotocol/adcp repository |
| 185 | +2. **Add runtime validation** - Python SDK should validate these constraints even if schemas don't |
| 186 | +3. **Document workaround** - Add validation in SDK with clear error messages |
| 187 | +4. **Track schema version** - When upstream fixes schemas, update SDK to rely on schema validation |
| 188 | + |
| 189 | +## Example Invalid Data That Currently Passes Validation |
| 190 | + |
| 191 | +### Product with both `property_ids` and `property_tags`: |
| 192 | +```json |
| 193 | +{ |
| 194 | + "product_id": "test", |
| 195 | + "publisher_properties": [ |
| 196 | + { |
| 197 | + "publisher_domain": "example.com", |
| 198 | + "property_ids": ["site1", "site2"], |
| 199 | + "property_tags": ["news", "sports"] // Should be rejected! |
| 200 | + } |
| 201 | + ] |
| 202 | +} |
| 203 | +``` |
| 204 | + |
| 205 | +### Product with neither `property_ids` nor `property_tags`: |
| 206 | +```json |
| 207 | +{ |
| 208 | + "product_id": "test", |
| 209 | + "publisher_properties": [ |
| 210 | + { |
| 211 | + "publisher_domain": "example.com" // Should require one! |
| 212 | + } |
| 213 | + ] |
| 214 | +} |
| 215 | +``` |
| 216 | + |
| 217 | +### Agent with multiple authorization methods: |
| 218 | +```json |
| 219 | +{ |
| 220 | + "url": "https://agent.example.com", |
| 221 | + "authorized_for": "All properties", |
| 222 | + "property_ids": ["site1"], |
| 223 | + "property_tags": ["news"], // Should be rejected! |
| 224 | + "properties": [{ ... }] // Should be rejected! |
| 225 | +} |
| 226 | +``` |
| 227 | + |
| 228 | +## Testing |
| 229 | + |
| 230 | +Run schema validation against these invalid examples to confirm they incorrectly pass. |
| 231 | + |
| 232 | +## References |
| 233 | + |
| 234 | +- Product schema: `https://adcontextprotocol.org/schemas/v1/core/product.json` |
| 235 | +- AdAgents schema: `https://adcontextprotocol.org/schemas/v1/adagents.json` |
| 236 | +- JSON Schema `oneOf`: https://json-schema.org/understanding-json-schema/reference/combining#oneOf |
0 commit comments