BRD-829: Features & attribute key-value map SDK support#47
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the search experience by enabling the display of human-readable facet names instead of technical IDs. It introduces a mechanism within the SDK to transmit a feature key-value map, which the backend then utilizes to provide localized and user-friendly labels for search facets, improving clarity and usability for end-users. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds support for features_key_value_map to the search settings, allowing for feature facet name translation. The changes are well-structured, following the existing immutable value object and builder patterns. The new functionality is also thoroughly covered by unit tests. I have one minor suggestion to make the code slightly more concise.
| if ($this->featuresKeyValueMap !== null && count($this->featuresKeyValueMap) > 0) { | ||
| $result['features_key_value_map'] = $this->featuresKeyValueMap; | ||
| } |
There was a problem hiding this comment.
For checking if a nullable array property is not null and not empty, you can use the !empty() language construct. It's more concise and idiomatic in PHP, and achieves the same result as the current condition.
if (!empty($this->featuresKeyValueMap)) {
$result['features_key_value_map'] = $this->featuresKeyValueMap;
}|
@claude review this. IS this correct & has no bugs? |
|
Claude finished @SteponasK's task in 1m 10s —— View job Code Review
Overall: The implementation is correct and has no bugs. The code follows the existing patterns cleanly, and test coverage is thorough. Here's a detailed breakdown:
|
| Test | Coverage |
|---|---|
testConstructorWithFeaturesKeyValueMap |
Constructor assignment |
testJsonSerializeIncludesFeaturesKeyValueMap |
Serialization when set |
testJsonSerializeOmitsNullFeaturesKeyValueMap |
Omission when null |
testJsonSerializeOmitsEmptyFeaturesKeyValueMap |
Omission when empty array |
testFromSearchConfigurationExtractsFeaturesKeyValueMap |
Extraction from config array |
testFromSearchConfigurationHandlesMissingFeaturesKeyValueMap |
Missing key fallback |
testWithMethodsPreserveFeaturesKeyValueMap |
All with*() methods preserve the map |
testBuildWithFeaturesKeyValueMap |
Builder → request → serialization flow |
testFluentInterfaceReturnsSelf |
Fluent interface chain |
One minor gap: testResetClearsAllState doesn't explicitly assert that featuresKeyValueMap is null after reset. This is low risk since the existing test structure (expecting an exception on missing appId) only validates the reset happened, not each individual field. Not a bug, just a completeness note.
Summary
The implementation is correct with no bugs. Logic, serialization, immutability, and builder pattern are all properly implemented. The only actionable item is the missing withFeaturesKeyValueMap() if API symmetry is desired — but this is not a correctness issue.
Adds a separate attribute_key_value_map alongside the existing features_key_value_map for independent feature/attribute facet name translation.
f2446a4 to
c0af154
Compare
Summary
attributeKeyValueMapproperty toSearchSettingsRequestalongside existingfeaturesKeyValueMapSearchSettingsRequestBuilderwithattributeKeyValueMap()builder methodfromSearchConfiguration()to readattribute_key_value_mapfrom config arraysattribute_key_value_mapin JSON output when non-emptyBusiness Case
Key-value maps enable human-readable facet names (e.g., "Color", "Size") instead of numeric IDs (e.g., "5", "12") for end-users browsing search facets/filters.
Separate maps allow independent optionality:
When maps are populated
Backwards Compatibility
$attributeKeyValueMapparameter defaults tonull— all existing callers continue to workfromSearchConfiguration()gracefully handles missingattribute_key_value_mapkeyTest Plan