Skip to content

fix: validate required 'log' key during HAR deserialization#156

Merged
deviantintegral merged 1 commit intomainfrom
claude/fix-log-key-initialization-h1dEG
Dec 16, 2025
Merged

fix: validate required 'log' key during HAR deserialization#156
deviantintegral merged 1 commit intomainfrom
claude/fix-log-key-initialization-h1dEG

Conversation

@deviantintegral
Copy link
Owner

Add PostDeserialize validation to ensure HAR files contain the required 'log' key. Previously, missing 'log' keys would cause uninitialized property errors when accessing getLog(). Now, deserializeHar() properly throws JMS\Serializer\Exception\RuntimeException with a clear message.

Changes:

  • Add PostDeserialize annotation to Har::validateLogProperty()
  • Add MissingLogKeyTest with tests for missing/invalid log keys
  • Fix 18_bom.har fixture to be a valid minimal HAR file with BOM
  • Add missing-log.har test fixture for edge case testing

The solution uses JMS Serializer's PostDeserialize annotation instead of manual JSON parsing, keeping the validation logic within the domain model.

Add PostDeserialize validation to ensure HAR files contain the required 'log'
key. Previously, missing 'log' keys would cause uninitialized property errors
when accessing getLog(). Now, deserializeHar() properly throws
JMS\Serializer\Exception\RuntimeException with a clear message.

Changes:
- Add PostDeserialize annotation to Har::validateLogProperty()
- Add MissingLogKeyTest with tests for missing/invalid log keys
- Fix 18_bom.har fixture to be a valid minimal HAR file with BOM
- Add missing-log.har test fixture for edge case testing

The solution uses JMS Serializer's PostDeserialize annotation instead of
manual JSON parsing, keeping the validation logic within the domain model.
@deviantintegral deviantintegral marked this pull request as ready for review December 16, 2025 21:27
@deviantintegral
Copy link
Owner Author

I confirmed the updated 18_bom.har file still contains the BOM:

$ xxd tests/fixtures/18_bom.har | head
00000000: efbb bf7b 0a20 2022 6c6f 6722 3a20 7b0a  ...{.  "log": {.

@deviantintegral deviantintegral merged commit 9d938fb into main Dec 16, 2025
8 checks passed
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.

2 participants