Skip to content

fix(apigw): register HttpMethod in logging serialization context#75

Open
Im5tu wants to merge 1 commit into
mainfrom
fix/apigw-logging-httpmethod
Open

fix(apigw): register HttpMethod in logging serialization context#75
Im5tu wants to merge 1 commit into
mainfrom
fix/apigw-logging-httpmethod

Conversation

@Im5tu

@Im5tu Im5tu commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Summary

Microsoft.Extensions.Http logs the request method when an outbound HttpClient request starts ("Start processing HTTP request {HttpMethod} {Uri}"). The boxed HttpMethod reached the JSON logger and DictionaryJsonConverter threw because the ApiGateway LoggingSerializationContext had no type info for it, producing recurring errors:

An error occurred while writing to logger(s). (type: System.Net.Http.HttpMethod is not supported by LoggingSerializationContext.)

This registers HttpMethod in the ApiGateway context, mirroring the Core logging context.

Notes

  • Serialises as "httpMethod": { "method": "GET" } (object form).
  • The converter still throws on other unregistered types a third-party library might log (Uri, HttpStatusCode, TimeSpan, …). A graceful ToString() fallback in DictionaryJsonConverter would close that whole class — out of scope here by request.

Testing

  • dotnet build on Goa.Functions.ApiGateway — 0 errors, 0 warnings.

🤖 Generated with Claude Code

Microsoft.Extensions.Http logs the HttpRequestMessage method when an
outbound HttpClient request starts. The value reaches the JSON logger as
a boxed HttpMethod, and DictionaryJsonConverter threw because the
ApiGateway LoggingSerializationContext had no type info for it, causing
'An error occurred while writing to logger(s)'. Register HttpMethod,
mirroring the Core logging context.
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 51878ed0-7294-4ec4-ad7b-7e312fc45a06

📥 Commits

Reviewing files that changed from the base of the PR and between d3d6de3 and 8923c7d.

📒 Files selected for processing (1)
  • src/Functions/Goa.Functions.ApiGateway/LoggingSerializationContext.cs

📝 Walkthrough

Walkthrough

This PR extends the logging serialization context to support JSON serialization of System.Net.Http.HttpMethod. The change adds a namespace import and registers the type in the source-generated serialization configuration, enabling the logging layer to serialize HTTP method objects.

Changes

HttpMethod Serialization Support

Layer / File(s) Summary
Add HttpMethod to logging serialization context
src/Functions/Goa.Functions.ApiGateway/LoggingSerializationContext.cs
Import System.Net.Http namespace and register HttpMethod as a [JsonSerializable] type so the generated serialization context can handle HTTP method objects.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description provides comprehensive context about the problem, solution, and testing, but does not address the checklist items from the repository template. Complete the provided checklist to document which checks were performed (tests, AOT compatibility, documentation) and their status.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically summarizes the main change: registering HttpMethod in the logging serialization context for the API Gateway component.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/apigw-logging-httpmethod

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant