Skip to content

fix(AZURE_DNS): bug: intermittent "resource type does not match the type in the request body" errors - #5040

Merged
TomOnTime merged 1 commit into
mainfrom
fix_azure_readonly_type
Oct 26, 2026
Merged

TomOnTime merged 1 commit into
mainfrom
fix_azure_readonly_type

Conversation

@TomOnTime

Copy link
Copy Markdown
Collaborator

Problem

Integration tests on AZURE_DNS intermittently fail on record create/update:

PUT .../dnsZones/<zone>/NS/@
RESPONSE 400: 400 Bad Request
"The resource type 'Microsoft.Network/dnsZones/NS' does not match the type in the request body 'NS'."

Cause

recordToNativeDiff2 set RecordSet.Type to the bare rtype (e.g. "NS"). That field is READ-ONLY in the API, but the SDK's MarshalJSON still serializes it, so every PUT sent "type": "NS". Azure appears to have started validating this field against the URL's resource type, apparently on only some backends, which is why the failures are intermittent. The error was seen on NS records, but any type is affected.

Fix

Don't set RecordSet.Type on outgoing record sets. Track the type in a local variable (including the AZURE_ALIAS_* case) and use it only to pick the RecordType for the URL path.

AZURE_PRIVATE_DNS had the identical pattern (its SDK also serializes type), so the same fix is applied there.

Testing

  • Unit tests for providers/azuredns and providers/azureprivatedns pass.
  • Integration tests against live Azure still need to be re-run (several times, given the intermittency).

🤖 Generated with Claude Code

…ype in the request body" errors

RecordSet.Type is READ-ONLY in the Azure API, but the SDK still
serializes it. We set it to the bare rtype (e.g. "NS"), which Azure now
(sometimes) rejects because it doesn't match the URL's resource type
("Microsoft.Network/dnsZones/NS"). Stop setting it; track the type in a
local variable instead. Same fix applied to AZURE_PRIVATE_DNS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TomOnTime

Copy link
Copy Markdown
Collaborator Author

We've had random failures like this for years. Retrying always works. I finally thought to ask Claude if they had a suggestion. Turns out, the fix was easy:
CC @vatsalyagoel @matthewmgamble @mhenderson-so

@TomOnTime
TomOnTime merged commit 329c40e into main Oct 26, 2026
37 of 39 checks passed
@TomOnTime
TomOnTime deleted the fix_azure_readonly_type branch October 26, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant