Skip to content

Conversation

@greghuels
Copy link
Collaborator

Eppo Internal:

🎟️ Fixes FFESUPPORT-458

Summary

Fixes #51 - crash in parseConfigResponse when receiving invalid or non-object JSON input.

  • Added validation to check that input JSON is an object before calling contains() method
  • Added comprehensive test coverage for malformed input edge cases

Root Cause

The parseConfigResponse(const nlohmann::json& j) function called j.contains("flags") without first validating that j is a JSON object. In nlohmann::json, calling contains() on a non-object type (null, array, number, string, boolean) throws a type_error.306 exception, causing the EXCEPTION_ACCESS_VIOLATION_READ crash reported in the issue.

This could occur when the backend returns empty, corrupt, or unexpected responses.

Test plan

  • Added 11 new test cases covering edge cases:
    • Empty string input
    • Null JSON input (both as json object and string "null")
    • Array JSON input (both as json object and string "[]")
    • Number JSON input
    • String JSON input
    • Boolean JSON input
    • Malformed JSON string
    • Truncated JSON string
  • All 125 existing tests continue to pass

Comment on lines +632 to +633
result.errors.push_back("ConfigResponse: Expected a JSON object, got " +
std::string(j.type_name()));
Copy link
Member

Choose a reason for hiding this comment

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

consider another log line that prints out the received configuration to give them a totally self service way to iterate; alternatively does this error give them a strong enough signal that they could catch and print it themselves?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The current error message includes the JSON type name (e.g., "Expected a JSON object, got null" or "got array"), which should give a good signal about what happened. Since parseConfigResponse returns a ParseResult with the error in result.errors, consuming apps can catch and log the full input themselves. So we should be good 👍

@greghuels greghuels merged commit 9a2fc90 into main Jan 27, 2026
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.

Crash in eppoclient::parseConfigResponse

3 participants