Commit 38cf510
[Darwin] Surface granular pairing-failure context in MTRError + DNS-SD / BLE error preservation
Consumers of MTRError currently see most commissioning failures surface
as a single "Error Domain=com.apple.MatterSupport Code=1 (null)". This
change plumbs structured detail into the bridged NSError so callers can
disambiguate failure modes, and tightens Darwin's CoreBluetooth / DNS-SD
error mapping at the same time.
Scope: this commit is intentionally limited to the Darwin framework
(MTRError), two new core DNS-SD CHIP_ERROR codes + their descriptions,
and the Darwin platform glue (DnssdError mapping, BLE error
preservation). It is additive only - it touches 13 files and reverts
nothing on master. The earlier core-controller plumbing
(CompletionStatus widening, DevicePairingDelegate overload, PASE/CASE
status-code mapping) is already merged on master via #72227/#72228 and is
NOT part of this commit.
Darwin framework (MTRError):
- Add NSError userInfo keys with unprefixed string values
(MTR_PROVISIONALLY_AVAILABLE):
MTRAttestationVerificationResultKey (= @"attestationVerificationResult")
MTRDeviceBasicInformationVendorIDKey (= @"deviceBasicInformationVendorID")
MTRDeviceBasicInformationProductIDKey (= @"deviceBasicInformationProductID")
MTRUnderlyingErrorCodeKey (= @"errorCode" - same string as the key
already documented for MTRErrorCodeGeneralError).
The Device*BasicInformation* names reflect what the keys actually
store: the VID/PID the device asserts in its BasicInformation cluster,
which is NOT guaranteed to match the device's certification declaration
(mismatch is itself one of the attestation-failure modes).
- Surface AttestationVerificationResult enum + BasicInformation VID/PID
in attestation-failure NSErrors.
- New errorForCHIPErrorCode:logContext:additionalUserInfo: overload
lets bridge call sites attach attestation metadata without losing the
existing MTRErrorHolder association, and merges additionalUserInfo on
both the IM-status and core-error bridge paths (framework keys win).
- NSError (Matter) category: mtr_underlyingMatterErrorSourceFile and
mtr_underlyingMatterErrorSourceLine read source location on demand from
the existing MTRErrorHolder associated object via a single helper.
DNS-SD codes (src/lib/core):
- New CHIP_ERROR_DNSSD_NXDOMAIN (0xBE) - DNS-SD operational instance
does not exist.
- New CHIP_ERROR_DNSSD_SERVICE_NOT_RUNNING (0xC7) - DNS-SD platform
service is not running.
- Description arms in CHIPError.cpp; test entries in
TestCHIPErrorStr.cpp; ERROR_CODES.md regenerated.
Platform/Darwin:
- DnssdError.cpp: map kDNSServiceErr_NoSuchName / NoSuchRecord to
CHIP_ERROR_DNSSD_NXDOMAIN, kDNSServiceErr_ServiceNotRunning to
CHIP_ERROR_DNSSD_SERVICE_NOT_RUNNING, kDNSServiceErr_Timeout to
CHIP_ERROR_TIMEOUT (instead of collapsing to CHIP_ERROR_INTERNAL).
- BleConnectionDelegateImpl.mm: WrapCBErrorCodeAsKOS preserves the
CoreBluetooth NSError.code in a kOS-range CHIP_ERROR for triage, with
a 24-bit overflow guard that falls back to the cross-platform
BLE_ERROR_GATT_* sentinel; the existing HandleConnectionError contract
is unchanged for non-Darwin consumers.
Tests:
- MTRErrorMappingTests.m (new): MTRUnderlyingErrorCodeKey population +
round-trip via errorToCHIPIntegerCode:, pins all 4 userInfo key string
values (rename guard), proves the new key resolves to the @"errorCode"
string already documented for MTRErrorCodeGeneralError, and guards
additionalUserInfo merge on both the IM-status and core-error paths.
- MTRErrorTests.m: basename-only source-path assertions +
MTRErrorBasenameForPath mixed-separator coverage.
- TestCHIPErrorStr.cpp: the 2 new DNS-SD codes (harness asserts each
listed code yields a non-default description).
Known test-coverage limitations:
- DnssdError.cpp's DNSServiceErrorType -> CHIP_ERROR mapping has no
direct unit test: src/platform/Darwin has no unit-test target, and
standing one up for a 3-case switch is disproportionate. The underlying
error codes are unit-tested in TestCHIPErrorStr.cpp.
- WrapCBErrorCodeAsKOS is a file-local static inline; testing it directly
would require exposing a triage helper in the platform API surface,
which is not worth the API cost for a defensive overflow guard
(CoreBluetooth codes are documented small non-negative integers).
- Attestation-key population in MTRDeviceAttestationDelegateBridge.mm
requires an end-to-end attestation failure to exercise and is not unit
tested.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 8a162c6 commit 38cf510
16 files changed
Lines changed: 1162 additions & 72 deletions
File tree
- docs/ids_and_codes
- src
- darwin/Framework
- CHIPTests
- CHIP
- lib/core
- tests
- platform
- Darwin
- dnssd
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
| |||
146 | 147 | | |
147 | 148 | | |
148 | 149 | | |
| 150 | + | |
149 | 151 | | |
150 | 152 | | |
151 | 153 | | |
| |||
Lines changed: 19 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | 65 | | |
69 | 66 | | |
70 | 67 | | |
| |||
75 | 72 | | |
76 | 73 | | |
77 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
78 | 88 | | |
79 | 89 | | |
80 | 90 | | |
| |||
92 | 102 | | |
93 | 103 | | |
94 | 104 | | |
95 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
96 | 108 | | |
97 | 109 | | |
98 | 110 | | |
| |||
111 | 123 | | |
112 | 124 | | |
113 | 125 | | |
114 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
115 | 129 | | |
116 | 130 | | |
117 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
27 | 74 | | |
28 | 75 | | |
29 | 76 | | |
| |||
35 | 82 | | |
36 | 83 | | |
37 | 84 | | |
38 | | - | |
| 85 | + | |
39 | 86 | | |
40 | 87 | | |
41 | 88 | | |
42 | 89 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
47 | 101 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
52 | 106 | | |
53 | | - | |
54 | | - | |
| 107 | + | |
| 108 | + | |
55 | 109 | | |
56 | | - | |
57 | | - | |
| 110 | + | |
| 111 | + | |
58 | 112 | | |
59 | 113 | | |
60 | 114 | | |
| |||
125 | 179 | | |
126 | 180 | | |
127 | 181 | | |
128 | | - | |
| 182 | + | |
129 | 183 | | |
130 | 184 | | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
158 | 212 | | |
159 | | - | |
160 | | - | |
| 213 | + | |
| 214 | + | |
161 | 215 | | |
162 | 216 | | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
163 | 253 | | |
0 commit comments