Skip to content

Conversation

@kzu
Copy link
Member

@kzu kzu commented Jun 13, 2025

This helps diagnose the actual issue, since it usually stems from the payload we're trying to send, and just the response error wouldn't be enough to diagnose and fix.

This helps diagnose the actual issue, since it usually stems
from the payload we're trying to send, and just the response
error wouldn't be enough to diagnose and fix.
@kzu kzu added the enhancement New feature or request label Jun 13, 2025
@kzu kzu requested a review from Copilot June 13, 2025 18:44
@kzu kzu enabled auto-merge (rebase) June 13, 2025 18:44
@kzu
Copy link
Member Author

kzu commented Jun 13, 2025

32 passed 32 passed 7 skipped

🧪 Details on Ubuntu 24.04.2 LTS

from dotnet-retest v0.7.1 on .NET 8.0.17 with 💜 by @devlooped

@kzu kzu merged commit eedb621 into main Jun 13, 2025
7 checks passed
@kzu kzu deleted the dev/payload branch June 13, 2025 18:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances error logging by including the outgoing payload alongside the HTTP response error, making debugging of failed WhatsApp API calls easier.

  • Introduced jsonOptions to standardize JSON serialization settings.
  • Changed error handling to serialize both payload and parsed response into a single JSON block.
  • Updated the logger and exception to include the serialized payload context.
Comments suppressed due to low confidence (2)

src/WhatsApp/WhatsAppClient.cs:68

  • [nitpick] The variable name error is ambiguous and matches the serialized property name. Consider renaming it to errorDetailsJson and using a more specific property name like responseError for clarity.
var error = JsonSerializer.Serialize(new

src/WhatsApp/WhatsAppClient.cs:70

  • Logging the raw payload may expose sensitive data. Ensure that any personal or confidential fields are redacted or filtered before logging in production.
payload,

var error = JsonSerializer.Serialize(new
{
payload,
error = JsonNode.Parse(await result.Content.ReadAsStringAsync())
Copy link

Copilot AI Jun 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parsing the HTTP response content without handling parse errors could throw an exception if the content isn’t valid JSON and mask the original failure. Consider wrapping the parse call in a try/catch and falling back to the raw string on parse errors.

Copilot uses AI. Check for mistakes.
@devlooped devlooped locked and limited conversation to collaborators Jul 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants