Skip to content

Commit 9d85912

Browse files
authored
Merge branch 'main' into copilot/fix-extra-logging-non-root-commands
2 parents 2080355 + b3213ee commit 9d85912

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

DevProxy.Plugins/Mocking/MockResponsePlugin.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,19 @@ private static void ReplacePlaceholders(MockResponseResponse? response, Request
537537
return;
538538
}
539539

540+
var contentType = request.ContentType;
541+
// Only attempt to parse JSON if content-type is:
542+
// - null or empty (for backward compatibility)
543+
// - a JSON type (application/json, application/vnd.api+json, etc.)
544+
var isJsonContent = string.IsNullOrEmpty(contentType) ||
545+
contentType.Contains("json", StringComparison.OrdinalIgnoreCase);
546+
547+
if (!isJsonContent)
548+
{
549+
logger.LogDebug("Content-Type '{ContentType}' is not JSON. Skipping placeholder replacement", contentType);
550+
return;
551+
}
552+
540553
try
541554
{
542555
var requestBody = JsonSerializer.Deserialize<JsonElement>(request.BodyString, ProxyUtils.JsonSerializerOptions);

0 commit comments

Comments
 (0)