Skip to content

Include header, type and per-field errors in invalid-packet log#128

Merged
erwan-joly merged 1 commit intomasterfrom
improve-invalid-packet-log
Apr 22, 2026
Merged

Include header, type and per-field errors in invalid-packet log#128
erwan-joly merged 1 commit intomasterfrom
improve-invalid-packet-log

Conversation

@erwan-joly
Copy link
Copy Markdown
Contributor

@erwan-joly erwan-joly commented Apr 22, 2026

Summary

  • Log now resolves the header via [PacketHeader] attribute when packet.Header is null (outgoing packets don't set Header).
  • Adds full type name and per-validation-error Member=Value: ErrorMessage lines so the broken packet can be located in trace captures.

Before: Sending an invalid packet: null ["Invalid Enum value"]
After: Sending an invalid packet: header=tc_info type=NosCore.Packets.ServerPackets.UI.TcInfoPacket errors=[Sex=99: Invalid Enum value]

Test plan

  • dotnet build -c Release
  • dotnet test --filter TestCategory!=OPTIONAL-TEST

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved error messages for invalid packets to include detailed debugging information with packet type and expanded error context.
  • Chores

    • Updated package version to 7.1.0.

Previously logged `null ["Invalid Enum value"]` because outgoing
packets don't set Header and ValidationResult renders without member
names. Now falls back to [PacketHeader] attr and formats each error as
Member=Value: ErrorMessage so the offending packet can be located in
trace files.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 22, 2026

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

Enhanced packet validation error logging in NetworkClient.cs by adding reflection-based context extraction for header and error details. Updated corresponding localization strings to reflect new placeholder format (header, type, errors). Version bumped to 7.1.0.

Changes

Cohort / File(s) Summary
Error Logging Enhancement
src/NosCore.Networking/NetworkClient.cs, src/NosCore.Networking/Resource/LocalizedResources.resx, src/NosCore.Networking/Resource/LocalizedResources.fr.resx
Enhanced packet validation failure logging with reflection-based extraction of header identification and flattened error messages. Updated localization strings to support new placeholder structure: header, type, and errors.
Version Update
src/NosCore.Networking/NosCore.Networking.csproj
Incremented package version from 7.0.0 to 7.1.0.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: adding header, type, and per-field errors to invalid-packet logging, which aligns with the core modifications across NetworkClient.cs and resource files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 improve-invalid-packet-log

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

@erwan-joly erwan-joly merged commit bbd4302 into master Apr 22, 2026
3 of 4 checks passed
@erwan-joly erwan-joly deleted the improve-invalid-packet-log branch April 22, 2026 11:20
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