Feature / v2 endpoint#38
Conversation
Summary of ChangesHello @tomas862, 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 introduces a new version of the synchronization SDK, specifically designed to interact with the V2 API. It encapsulates all V2-specific logic and configurations into new classes, ensuring a clear separation from existing API versions. The changes aim to provide a robust and well-tested client for the V2 API, covering a wide range of functionalities from index management to bulk data operations, with an emphasis on correct data handling and authentication. 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. 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 introduces the V2 endpoint for the Sync SDK, including a new configuration object, the SDK class itself, and extensive unit and BDD tests. The implementation is mostly solid, but I've identified a critical issue in the testability of the SyncV2Sdk class which invalidates the current unit tests. I've also pointed out a potential security/correctness issue with URL parameter encoding and a maintainability concern regarding confusing method names. Addressing the testability issue is crucial to ensure the long-term stability and correctness of the SDK.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ement) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ement) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…nagement) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…nagement) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add full CRUD operations for search settings:
- createSearchSettings(array $settings): POST to api/v2/configuration
- getSearchSettings(string $appId): GET from api/v2/configuration/{app_id}
- updateSearchSettings(string $appId, array $settings): PUT to api/v2/configuration/{app_id}
- deleteSearchSettings(string $appId): DELETE from api/v2/configuration/{app_id}
All methods return raw API responses.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add comprehensive unit tests for all SyncV2Sdk public methods with mocked HttpClient. Tests verify: - app_id is correctly included in URL paths - Bearer token authentication is configured - Data is passed through without modification - All endpoints use v2 API version format - Raw API responses are returned correctly Also add BDD feature files documenting expected behavior for: - Main SDK operations (sync_v2_sdk.feature) - Authentication handling (sync_v2_authentication.feature) - URL path construction (sync_v2_url_paths.feature) - Data passthrough behavior (sync_v2_data_passthrough.feature) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add FieldType enum with values: text, keyword, double, integer, boolean, image_url, variants - Add VariantAttribute ValueObject with id, type, locale_aware properties - Add FieldDefinition immutable ValueObject with name, type, attributes - Add FieldDefinitionBuilder with fluent API for constructing field definitions - Add comprehensive unit tests including OpenAPI example verification Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Create IndexCreateRequest immutable ValueObject with locales and fields
- Create IndexCreateRequestBuilder with fluent API (addLocale, addField, build)
- Validate locales match pattern ^[a-z]{2}-[A-Z]{2}$
- Validate at least one locale and one field required
- jsonSerialize() outputs exact structure matching IndexCreateRequestV2App schema
- Unit tests compare output against OpenAPI 'Darbo drabuziai client' example
- Update SyncV2Sdk::createIndex() to accept IndexCreateRequest
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add MatchMode enum with values: exact, fuzzy, phrase_prefix - Add SearchFieldConfig immutable ValueObject with field, position, boost_multiplier, and match_mode properties - Add SearchFieldConfigBuilder with fluent with*() API - Validates position >= 1 and boost_multiplier between 0.01 and 100.0 - match_mode defaults to fuzzy if not specified - jsonSerialize() outputs structure matching SearchFieldConfigV2 schema - Unit tests verify validation boundaries and JSON output Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add FuzzyMode enum with values: auto, fixed - Add FuzzyMatchingConfig immutable ValueObject with enabled, mode, min_similarity - Validates min_similarity between 0 and 2 - Provides with*() methods: withEnabled(), withMode(), withMinSimilarity() - Defaults: enabled=true, mode=auto, min_similarity=2 - jsonSerialize() outputs structure matching FuzzyMatchingConfig schema - Full unit test coverage for both enum and ValueObject Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add BoostAlgorithm enum with: logarithmic, linear, square_root - Add PopularityBoostConfig immutable ValueObject with: - enabled, field, algorithm, max_boost properties - max_boost validation (1.0 to 10.0) - with*() methods for all properties - jsonSerialize() matching schema - Defaults: algorithm=logarithmic, max_boost=2.0 - Full unit test coverage Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
@claude review |
|
Claude finished @tomas862's task in 2m 7s —— View job Code Review: Feature / v2 endpointI've completed my review of this PR. This is a substantial implementation (27,273 additions across 100 files) introducing a new V2 SDK for Brad Search synchronization. Overall, the code demonstrates good architecture with immutable value objects, comprehensive validation, and extensive test coverage. However, I've identified several critical and high-priority issues that should be addressed. Critical Issues1. Testability Issue: Direct
|
|
@claude review latest changes |
|
Claude finished @tomas862's task in 1m 57s —— View job Code Review: Latest ChangesI've completed my review of the latest changes on the feature/v2-endpoint branch. Recent Commits Analyzed
Critical Issue: FIXED ✅The testability issue has been successfully resolved! The most significant improvement in commit Example of the fix (line 64): public function createIndex(IndexCreateRequest $request): IndexCreationResponse
{
$response = $this->getHttpClient()->post( // ✅ Now using accessor
$this->baseApiPath . 'index',
$request->jsonSerialize()
);
return IndexCreationResponse::fromArray($response);
}The test suite in
Remaining IssuesHigh Priority: Missing URL Encoding
|
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
The brad-search API returns version as a string with 'v' prefix (e.g., 'v4').
PHP's (int) cast converts 'v4' to 0, causing version activation to fail.
This commit adds parseVersion() method that:
- Strips 'v' or 'V' prefix from version strings
- Converts to integer correctly ('v4' → 4)
- Handles both string and integer inputs
- Validates format and throws InvalidArgumentException for invalid formats
This fixes V2 synchronization issues where version 0 would cause 404 errors
during index activation.
Changed OperationResult to use 'type' field instead of 'operation_type' to match what BulkOperation sends in requests. This fixes the field name mismatch that was causing bulk operations to fail with 'Missing required field: operation_type'. Changes: - OperationResult.php: Changed fromArray() to expect 'type' instead of 'operation_type' - OperationResult.php: Changed jsonSerialize() to output 'type' for consistency - Updated all test files to use 'type' field name This ensures consistency across the SDK - we send 'type' and expect 'type' back.
BREAKING CHANGE: BulkOperationsResponse now returns per-item results instead of per-operation summaries
Changes:
- Created ItemResult class to represent per-item results matching Golang API
- Fields: id, operation, status, error
- Replaces old OperationResult with items_processed/items_failed
- Updated BulkOperationsResponse to use ItemResult[]
- Added warnings and processingTimeMs optional fields
- Added getSuccessfulResults() helper method
- Updated all tests to match new structure
- Updated mock responses in integration tests
The new structure matches the actual brad-search V2 API which returns:
{
"status": "success",
"total_operations": 10,
"successful_operations": 9,
"failed_operations": 1,
"results": [
{"id": "prod-1", "operation": "index_products", "status": "created"},
{"id": "prod-2", "operation": "index_products", "status": "error", "error": "Invalid price"}
]
}
This provides full granularity for retry logic and error tracking.
Fixes: #issue-with-bulk-operations-field-mismatch
Code review\n\nNo issues found. Checked for bugs and CLAUDE.md compliance. |
No description provided.