Skip to content

[LFX-V2-199] Query Service: org search - suggestions endpoint#16

Merged
mauriciozanettisalomao merged 2 commits intolinuxfoundation:mainfrom
mauriciozanettisalomao:feat/lfxv2-199-org-search-suggestions
Sep 12, 2025
Merged

[LFX-V2-199] Query Service: org search - suggestions endpoint#16
mauriciozanettisalomao merged 2 commits intolinuxfoundation:mainfrom
mauriciozanettisalomao:feat/lfxv2-199-org-search-suggestions

Conversation

@mauriciozanettisalomao
Copy link
Copy Markdown
Contributor

Overview

This pull request introduces a new "organization suggestions" feature for typeahead search in the query service, along with supporting updates across the API, service implementation, CLI, and deployment configuration. The main changes add a new endpoint for organization suggestions, update the data model and CLI to support it, and enhance configuration for external autocomplete services.

Note: There’s a specific ticket to improve unit tests (and maybe integration tests).

Test Results Summary

1.1 /query/orgs/suggest?v=1&query=magazine123

  • Status: 200 OK
  • Response: Returns 5 organization suggestions including "Magazine Luiza", "Magazine Voce", "Magazines.com", etc.
  • Response Time: Fast
  • Request ID: c168b67c-b6cb-43cb-9d4c-92ddfbe4df48

1.2 /query/orgs/suggest?v=1&query=linux

  • Status: 200 OK
  • Request ID: 95510d11-9bfe-4d66-a981-999bb63bb55b
  • Response Time: Fast

Organizations Found:

  1. LinuxHint (linuxhint.com) - with logo
  2. Linux Mint (linuxmint.com) - with logo
  3. Linux Inside: The Ideal Blog for Sysadmins & Geeks (tecmint.com) - with logo
  4. Linux Kernel Archives (kernel.org) - with logo
  5. LinuxQuestions.org (linuxquestions.org) - with logo

2. /query/orgs?v=1&name=magazine123

  • Status: 200 OK
  • Response: Found organization "Magazine 123" with domain "magazine123.com.br"
  • Response Time: Fast
  • Request ID: 05c4dcc2-fe49-43ff-9325-bf22f8f56936

3. /query/orgs?v=1&domain=linuxfoundation.org

  • Status: 200 OK
  • Response: Found "The Linux Foundation" with detailed information including industry ("Internet Software & Services") and employee count ("51-250")
  • Response Time: Fast
  • Request ID: dcb70308-423f-4039-a5a3-d84741e3a763

Key Observations

  • All endpoints are working correctly and returning 200 OK responses
  • Authentication with the Bearer token is working properly
  • Each request includes a unique X-Request-Id header for tracking
  • The suggest endpoint returns multiple suggestions as expected
  • The search by name and domain endpoints return specific organization details

- Added a new endpoint for organization suggestions based on a search query.
- Integrated Clearbit's Autocomplete API for fetching organization suggestions.
- Updated the service layer to handle the new suggestion logic and response formatting.
- Enhanced the OpenAPI documentation to include the new endpoint and its parameters.
- Updated CLI commands to support the new suggest-orgs functionality.

Jira Ticket: https://linuxfoundation.atlassian.net/browse/LFXV2-199

Generated with [Cursor](https://cursor.com/)

Signed-off-by: Mauricio Zanetti Salomao <mauriciozanetti86@gmail.com>
Copilot AI review requested due to automatic review settings September 11, 2025 13:44
@mauriciozanettisalomao mauriciozanettisalomao requested a review from a team as a code owner September 11, 2025 13:44
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Sep 11, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds an organization suggestions (typeahead) feature: API and DSL types, HTTP route and auth rule, service handler and converters, domain criteria/models and port, Clearbit autocomplete client/config/models, mock and service implementations, Helm chart bump, and minor HTTP client logging/retry tweaks.

Changes

Cohort / File(s) Summary
Helm chart metadata
charts/lfx-v2-query-service/Chart.yaml
Bump chart version from 0.4.0 to 0.4.1.
Gateway routing and auth
charts/lfx-v2-query-service/templates/httproute.yaml, charts/lfx-v2-query-service/templates/ruleset.yaml
Change /query/orgs path match from Exact to PathPrefix; add RuleSet entry for GET /query/orgs/suggest with OIDC auth/contextualizer, allow-all authorizer, and JWT finalizer.
API design / types
design/query-svc.go, design/types.go
Add suggest-orgs endpoint (GET /query/orgs/suggest) and new DSL type OrganizationSuggestion (name, domain, logo).
Service handlers & converters
cmd/service/service.go, cmd/service/converters.go, cmd/service/providers.go
Add SuggestOrgs handler and converters; wire new CLEARBIT_AUTOCOMPLETE_BASE_URL env var into Clearbit config.
Domain models & port
internal/domain/model/organization.go, internal/domain/model/search_criteria.go, internal/domain/port/searcher.go
Add OrganizationSuggestion, OrganizationSuggestionsResult, OrganizationSuggestionCriteria; extend OrganizationSearcher interface with SuggestOrganizations.
Clearbit infra: client/config/models/searcher
internal/infrastructure/clearbit/client.go, .../config.go, .../models.go, .../searcher.go
Add AutocompleteBaseURL to config and DefaultConfig; generalize makeRequest to decode into a provided model; add SuggestCompanies calling Clearbit Autocomplete; add ClearbitCompanySuggestion model; implement SuggestOrganizations; enrich QueryOrganizations with domain lookup and simplified not-found handling.
Mock searcher
internal/infrastructure/mock/organization_searcher.go
Implement SuggestOrganizations returning up to 5 case-insensitive partial matches (Name, Domain, Logo=nil).
Application service
internal/service/organization_search.go
Add SuggestOrganizations on OrganizationSearch delegating to underlying searcher with logging and result-count metrics.
HTTP client adjustments
pkg/httpclient/client.go
Use log/slog for final failure logging; simplify RetryableError.Error() text; use http.Status* constants in status checks and retry logic.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Client
  participant GW as Gateway (HTTPRoute/RuleSet)
  participant QS as query-svc
  participant SVC as OrganizationSearch (app)
  participant SRCH as OrganizationSearcher (Clearbit)
  participant CB as Clearbit Autocomplete API

  C->>GW: GET /query/orgs/suggest?v=1&query=q\nAuthorization: Bearer ...
  rect #EBF5FF
    note over GW: OIDC auth (+optional contextualizer), allow-all, JWT finalizer
  end
  GW->>QS: Forward validated request
  QS->>QS: payload → OrganizationSuggestionCriteria
  QS->>SVC: SuggestOrganizations(criteria)
  SVC->>SRCH: SuggestOrganizations(ctx, criteria)
  SRCH->>CB: GET /autocomplete?query=q
  CB-->>SRCH: 200 OK [suggestions]
  SRCH-->>SVC: OrganizationSuggestionsResult
  SVC-->>QS: OrganizationSuggestionsResult
  QS->>QS: map domain model → API response
  QS-->>GW: 200 OK { suggestions: [...] }
  GW-->>C: 200 OK
Loading
sequenceDiagram
  autonumber
  participant QS as query-svc
  participant SVC as OrganizationSearch
  participant SRCH as Clearbit Searcher
  participant CB as Clearbit Company API

  note over QS,SRCH: Updated enrichment in QueryOrganizations
  QS->>SVC: QueryOrganizations(criteria: name)
  SVC->>SRCH: QueryOrganizations
  SRCH->>CB: FindCompanyByName(name)
  CB-->>SRCH: Company (may include domain)
  alt company has domain
    SRCH->>CB: FindCompanyByDomain(domain)
    CB-->>SRCH: Enriched Company
    SRCH->>SRCH: Replace with enriched result
  end
  SRCH-->>SVC: OrganizationResult or not-found error
  SVC-->>QS: Result or error
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

Pre-merge checks (3 passed, 2 warnings)

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Linked Issues Check ⚠️ Warning The implementation satisfies the core objective of LFXV2-199: the PR adds the suggest endpoint across the API (design/types.go), service handlers (cmd/service), domain models and ports, Clearbit client/config/searcher support, and mock implementations, demonstrating functional integration for suggestions. The testing objective in [LFXV2-198] is not met by the changeset: there is no evidence of new automated unit or integration test files in the provided summaries and the PR itself notes a separate ticket to improve tests, so the requirement for comprehensive automated tests remains outstanding. Therefore the linked-issues requirements are only partially satisfied. Include automated unit and integration tests that cover SuggestOrganizations and QueryOrganizations (success, no-results, and Clearbit error/timeout cases), add those test files to this PR or link the follow-up PR that implements them, and ensure CI passes before merging.
Out of Scope Changes Check ⚠️ Warning Most changes align with the org-suggestions objective, but there are unrelated cross-cutting edits—most notably pkg/httpclient/client.go where logging was switched to log/slog and RetryableError.Error() formatting was changed—which are not required by the feature and could alter global HTTP client behavior. These refactor-style changes increase the review surface and should be justified or separated from the feature PR; other modifications (Clearbit client/config, API/design, service, mocks, charts, ruleset) appear in-scope. Move the HTTP client refactor into a separate PR or provide a short justification and regression tests showing unchanged semantics, or revert those changes here so this PR remains focused on the org-suggestions feature.
✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title "[LFX-V2-199] Query Service: org search - suggestions endpoint" succinctly identifies the primary change (adding an organization suggestions/typeahead endpoint) and references the linked ticket; it is directly related to the changeset and understandable to reviewers. The wording is clear and concise and highlights the most important change without listing files. The ticket prefix and hyphenation are minor style noise but do not reduce clarity.
Description Check ✅ Passed The PR description is directly related to the changeset: it documents the new organization suggestions feature, lists affected areas (API, service, CLI, deployment), and includes manual test results demonstrating endpoint behavior and authentication. The description provides useful context and references the outstanding testing ticket (LFXV2-198), so it satisfies this lenient check. It is not off-topic.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between db33392 and 61fab90.

📒 Files selected for processing (1)
  • cmd/service/converters.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • cmd/service/converters.go
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request introduces a new organization suggestions feature for typeahead search functionality. It adds a new /query/orgs/suggest endpoint that provides organization suggestions based on a query string, extending the existing organization search capabilities.

  • Adds new SuggestOrgs endpoint for typeahead organization search
  • Extends Clearbit integration with Autocomplete API support
  • Updates configuration to support separate autocomplete service base URL

Reviewed Changes

Copilot reviewed 35 out of 35 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pkg/httpclient/client.go Improves error handling and logging in HTTP client
internal/service/organization_search.go Adds SuggestOrganizations business logic method
internal/infrastructure/mock/organization_searcher.go Implements mock organization suggestions functionality
internal/infrastructure/clearbit/searcher.go Adds Clearbit Autocomplete API integration and improves error handling
internal/infrastructure/clearbit/models.go Defines ClearbitCompanySuggestion model
internal/infrastructure/clearbit/config.go Adds autocomplete base URL configuration
internal/infrastructure/clearbit/client.go Implements SuggestCompanies method and refactors makeRequest
internal/domain/port/searcher.go Adds SuggestOrganizations interface method
internal/domain/model/*.go Defines organization suggestion domain models
gen/* Generated code for new suggest-orgs endpoint
design/*.go API design definitions for organization suggestions
cmd/service/*.go Service implementation and converters
charts/* Deployment configuration updates

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/infrastructure/clearbit/client.go (1)

84-110: Critical: json.Unmarshal target is incorrect; results won’t populate.

Passing &model (pointer to interface) prevents unmarshalling into the caller’s typed struct/slice; it will decode into a local interface instead. This yields zero-valued results and subtle bugs.

- if err := json.Unmarshal(resp.Body, &model); err != nil {
+ if err := json.Unmarshal(resp.Body, model); err != nil {
     return errors.NewUnexpected("failed to decode response", err)
 }
 return nil

Also consider refining HTTP error mapping:

-        case http.StatusNotFound:
-            return errors.NewNotFound("company not found")
+        case http.StatusNotFound:
+            return errors.NewNotFound("resource not found")
+        case http.StatusUnauthorized, http.StatusForbidden:
+            return errors.NewUnexpected("authentication failed", err)

Do you want a quick unit test to catch this regression (unmarshal into struct and slice)?

🧹 Nitpick comments (13)
charts/lfx-v2-query-service/templates/httproute.yaml (1)

16-20: PathPrefix may overmatch; consider adding Exact match for base path

PathPrefix "/query/orgs" also matches "/query/orgs-anything". If you want only the base and its subpaths, add an Exact match for "/query/orgs" and keep PathPrefix for "/query/orgs/*".

Example patch:

   rules:
   - matches:
-    - path:
-        type: PathPrefix
-        value: /query/orgs
+    - path:
+        type: Exact
+        value: /query/orgs
+    - path:
+        type: PathPrefix
+        value: /query/orgs/
       {{- if .Values.heimdall.enabled }}
       filters:
         - type: ExtensionRef

Also applies to: 28-34

internal/domain/model/search_criteria.go (1)

52-56: Add minimal validation/guards for suggestions query

Consider trimming and enforcing a small min/max length (e.g., 1–128) to protect upstream providers and avoid noisy calls on empty/long inputs. You can enforce at the converter layer if you prefer to keep the domain type simple.

internal/infrastructure/clearbit/models.go (1)

60-70: Logo field: optional encode-hint

If this type is ever marshaled (not just unmarshaled), add omitempty to align with domain JSON tags and avoid emitting nulls.

Apply:

 type ClearbitCompanySuggestion struct {
   // Name is the company name
   Name string `json:"name"`
   // Domain is the company's primary domain
   Domain string `json:"domain"`
   // Logo is the URL to the company's logo (can be null)
-  Logo *string `json:"logo"`
+  Logo *string `json:"logo,omitempty"`
 }
pkg/httpclient/client.go (1)

137-138: Retry 408 Request Timeout as well

Treat 408 as transient alongside 5xx and 429 to improve resilience on flaky networks.

Apply:

-    return retryableErr.StatusCode >= http.StatusInternalServerError || retryableErr.StatusCode == http.StatusTooManyRequests
+    return retryableErr.StatusCode >= http.StatusInternalServerError ||
+      retryableErr.StatusCode == http.StatusTooManyRequests ||
+      retryableErr.StatusCode == http.StatusRequestTimeout
design/types.go (1)

103-116: Validate domain (and consider URL format for logo).

Add a domain pattern to keep response schema consistent with query-orgs; optionally add URL format for logo.

 dsl.Attribute("domain", dsl.String, "Organization domain", func() {
   dsl.Example("linuxfoundation.org")
+  dsl.Pattern(`^[a-zA-Z0-9][a-zA-Z0-9-_.]*[a-zA-Z0-9]*\.[a-zA-Z]{2,}$`)
 })

(Optional) Consider adding a URL format to logo.

internal/infrastructure/clearbit/config.go (1)

64-66: Align default timeout with DefaultConfig (30s).

NewConfig defaults to 10s while DefaultConfig uses 30s. Use the same default to avoid surprises.

- if timeout == "" {
-   timeout = "10s"
- }
+ if timeout == "" {
+   timeout = "30s"
+ }
cmd/service/service.go (1)

100-109: Nil-safe conversion before building response.

Guard against a nil domain result to prevent a panic in the converter.

   result, errSuggestOrgs := s.organizationService.SuggestOrganizations(ctx, criteria)
   if errSuggestOrgs != nil {
     return nil, wrapError(ctx, errSuggestOrgs)
   }
 
+  if result == nil {
+    return &querysvc.SuggestOrgsResult{Suggestions: nil}, nil
+  }
+
   // Convert domain result to response
   res = s.domainOrganizationSuggestionsToResponse(result)
   return res, nil
internal/infrastructure/mock/organization_searcher.go (1)

137-150: Short-circuit after reaching the cap (avoid scanning full list).

Break once 5 suggestions are collected to keep mock behavior efficient with larger datasets.

   for _, org := range m.organizations {
     if strings.Contains(strings.ToLower(org.Name), query) || strings.Contains(strings.ToLower(org.Domain), query) {
       suggestions = append(suggestions, model.OrganizationSuggestion{
         Name:   org.Name,
         Domain: org.Domain,
         Logo:   nil, // Mock doesn't have logo data
       })
+      if len(suggestions) >= 5 {
+        break
+      }
     }
   }
 
-  // Limit to first 5 suggestions for realistic behavior
-  if len(suggestions) > 5 {
-    suggestions = suggestions[:5]
-  }
+  // Already capped during iteration
cmd/service/converters.go (1)

102-109: Normalize input query.

Trim whitespace to avoid accidental empty/space-only queries reaching the domain layer.

 func (s *querySvcsrvc) payloadToOrganizationSuggestionCriteria(ctx context.Context, p *querysvc.SuggestOrgsPayload) model.OrganizationSuggestionCriteria {
   criteria := model.OrganizationSuggestionCriteria{
-    Query: p.Query,
+    Query: strings.TrimSpace(p.Query),
   }
   return criteria
 }

Add import:

import "strings"
internal/infrastructure/clearbit/searcher.go (3)

51-55: Clarify enrichment logging to avoid confusion.

Log that enrichment happened and include the domain used; otherwise this looks identical to the earlier “found by domain” log.

-            slog.DebugContext(ctx, "found organization by domain", "name", clearbitCompany.Name)
+            slog.DebugContext(ctx, "enriched organization via domain",
+                "domain", clearbitCompany.Domain,
+                "name_before", clearbitCompany.Name,
+                "name_after", clearbitCompanyEnriched.Name)
             clearbitCompany = clearbitCompanyEnriched

59-63: Avoid error-level log + returning the same error (double logging).

Consider downgrading to Debug or removing the log to prevent duplicate error logs at call sites.

-    slog.ErrorContext(ctx, "error searching organization", "error", err)
+    slog.DebugContext(ctx, "error searching organization", "error", err)
     return nil, err

64-67: Return validation error when no criteria provided (not “not found”).

If both name and domain are nil, this is a bad request, not a not-found. Recommend explicit validation early.

Proposed guard near the start of the function (outside the changed hunk):

if criteria.Domain == nil && criteria.Name == nil {
    return nil, errors.NewValidation("either name or domain must be provided")
}

Would you like me to push a follow-up PR with this check and a unit test?

internal/infrastructure/clearbit/client.go (1)

63-82: Guard against missing Autocomplete base URL.

If AutocompleteBaseURL is empty, url.Parse yields a relative URL and the request will fail at runtime. Fail fast.

 func (c *Client) SuggestCompanies(ctx context.Context, query string) ([]ClearbitCompanySuggestion, error) {
+    if c.config.AutocompleteBaseURL == "" {
+        return nil, errors.NewUnexpected("autocomplete base URL not configured", nil)
+    }
     // Build the URL with query parameters
     u, err := url.Parse(fmt.Sprintf("%s/v1/companies/suggest", c.config.AutocompleteBaseURL))
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 96e5945 and db33392.

⛔ Files ignored due to path filters (17)
  • gen/http/cli/lfx_v2_query_service/cli.go is excluded by !**/gen/**
  • gen/http/openapi.json is excluded by !**/gen/**
  • gen/http/openapi.yaml is excluded by !**/gen/**
  • gen/http/openapi3.json is excluded by !**/gen/**
  • gen/http/openapi3.yaml is excluded by !**/gen/**
  • gen/http/query_svc/client/cli.go is excluded by !**/gen/**
  • gen/http/query_svc/client/client.go is excluded by !**/gen/**
  • gen/http/query_svc/client/encode_decode.go is excluded by !**/gen/**
  • gen/http/query_svc/client/paths.go is excluded by !**/gen/**
  • gen/http/query_svc/client/types.go is excluded by !**/gen/**
  • gen/http/query_svc/server/encode_decode.go is excluded by !**/gen/**
  • gen/http/query_svc/server/paths.go is excluded by !**/gen/**
  • gen/http/query_svc/server/server.go is excluded by !**/gen/**
  • gen/http/query_svc/server/types.go is excluded by !**/gen/**
  • gen/query_svc/client.go is excluded by !**/gen/**
  • gen/query_svc/endpoints.go is excluded by !**/gen/**
  • gen/query_svc/service.go is excluded by !**/gen/**
📒 Files selected for processing (18)
  • charts/lfx-v2-query-service/Chart.yaml (1 hunks)
  • charts/lfx-v2-query-service/templates/httproute.yaml (2 hunks)
  • charts/lfx-v2-query-service/templates/ruleset.yaml (1 hunks)
  • cmd/service/converters.go (1 hunks)
  • cmd/service/providers.go (3 hunks)
  • cmd/service/service.go (1 hunks)
  • design/query-svc.go (1 hunks)
  • design/types.go (1 hunks)
  • internal/domain/model/organization.go (1 hunks)
  • internal/domain/model/search_criteria.go (1 hunks)
  • internal/domain/port/searcher.go (1 hunks)
  • internal/infrastructure/clearbit/client.go (3 hunks)
  • internal/infrastructure/clearbit/config.go (3 hunks)
  • internal/infrastructure/clearbit/models.go (1 hunks)
  • internal/infrastructure/clearbit/searcher.go (2 hunks)
  • internal/infrastructure/mock/organization_searcher.go (1 hunks)
  • internal/service/organization_search.go (2 hunks)
  • pkg/httpclient/client.go (5 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
internal/domain/port/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place domain interfaces (ports) under internal/domain/port/

Files:

  • internal/domain/port/searcher.go
internal/domain/model/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core business entities (e.g., Resource, SearchCriteria, AccessCheck) under internal/domain/model/

Files:

  • internal/domain/model/search_criteria.go
  • internal/domain/model/organization.go
internal/infrastructure/mock/**

📄 CodeRabbit inference engine (CLAUDE.md)

Maintain mock implementations under internal/infrastructure/mock/

Files:

  • internal/infrastructure/mock/organization_searcher.go
design/**

📄 CodeRabbit inference engine (CLAUDE.md)

Keep Goa API design specifications in the design/ directory

Files:

  • design/types.go
  • design/query-svc.go
internal/service/**

📄 CodeRabbit inference engine (CLAUDE.md)

Keep service-layer orchestration logic in internal/service/

Files:

  • internal/service/organization_search.go
🧠 Learnings (2)
📚 Learning: 2025-09-10T17:40:14.123Z
Learnt from: CR
PR: linuxfoundation/lfx-v2-query-service#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-10T17:40:14.123Z
Learning: Applies to cmd/query_svc/query_svc.go : Keep the service implementation that connects Goa to domain logic in cmd/query_svc/query_svc.go

Applied to files:

  • cmd/service/converters.go
📚 Learning: 2025-09-08T18:22:24.173Z
Learnt from: mauriciozanettisalomao
PR: linuxfoundation/lfx-v2-query-service#13
File: charts/lfx-v2-query-service/templates/httproute.yaml:16-19
Timestamp: 2025-09-08T18:22:24.173Z
Learning: For the lfx-v2-query-service HTTPRoute configuration, OPTIONS method rules should not be included - only GET method constraints are needed for the /query/orgs endpoint.

Applied to files:

  • charts/lfx-v2-query-service/templates/httproute.yaml
  • charts/lfx-v2-query-service/templates/ruleset.yaml
🧬 Code graph analysis (10)
internal/domain/port/searcher.go (2)
internal/domain/model/search_criteria.go (1)
  • OrganizationSuggestionCriteria (53-56)
internal/domain/model/organization.go (1)
  • OrganizationSuggestionsResult (31-34)
internal/infrastructure/mock/organization_searcher.go (2)
internal/domain/model/search_criteria.go (1)
  • OrganizationSuggestionCriteria (53-56)
internal/domain/model/organization.go (2)
  • OrganizationSuggestionsResult (31-34)
  • OrganizationSuggestion (21-28)
cmd/service/service.go (1)
gen/query_svc/service.go (2)
  • SuggestOrgsPayload (155-162)
  • SuggestOrgsResult (166-169)
cmd/service/converters.go (3)
gen/query_svc/service.go (3)
  • SuggestOrgsPayload (155-162)
  • SuggestOrgsResult (166-169)
  • OrganizationSuggestion (84-91)
internal/domain/model/search_criteria.go (1)
  • OrganizationSuggestionCriteria (53-56)
internal/domain/model/organization.go (2)
  • OrganizationSuggestionsResult (31-34)
  • OrganizationSuggestion (21-28)
design/query-svc.go (3)
design/types.go (1)
  • OrganizationSuggestion (103-116)
internal/domain/model/organization.go (1)
  • OrganizationSuggestion (21-28)
gen/query_svc/service.go (1)
  • OrganizationSuggestion (84-91)
internal/service/organization_search.go (2)
internal/domain/model/search_criteria.go (1)
  • OrganizationSuggestionCriteria (53-56)
internal/domain/model/organization.go (1)
  • OrganizationSuggestionsResult (31-34)
internal/infrastructure/clearbit/client.go (3)
internal/infrastructure/clearbit/models.go (2)
  • ClearbitCompany (7-28)
  • ClearbitCompanySuggestion (61-70)
pkg/errors/client.go (2)
  • NewNotFound (39-46)
  • NewValidation (19-26)
pkg/errors/server.go (1)
  • NewUnexpected (19-26)
internal/infrastructure/clearbit/searcher.go (4)
pkg/errors/client.go (1)
  • NewNotFound (39-46)
internal/domain/port/searcher.go (1)
  • OrganizationSearcher (26-35)
internal/domain/model/search_criteria.go (1)
  • OrganizationSuggestionCriteria (53-56)
internal/domain/model/organization.go (2)
  • OrganizationSuggestionsResult (31-34)
  • OrganizationSuggestion (21-28)
internal/domain/model/organization.go (2)
design/types.go (1)
  • OrganizationSuggestion (103-116)
gen/query_svc/service.go (1)
  • OrganizationSuggestion (84-91)
internal/infrastructure/clearbit/config.go (1)
pkg/httpclient/config.go (1)
  • Config (11-23)
🔇 Additional comments (10)
charts/lfx-v2-query-service/Chart.yaml (1)

8-8: Chart version bump looks good

0.4.1 aligns with the new org-suggest surface; no concerns.

charts/lfx-v2-query-service/templates/ruleset.yaml (1)

64-79: New org-suggest rule is consistent with existing auth/finalizer pattern

GET-only, OIDC, optional contextualizer, allow_all, and aud set correctly. Matches the prior “no OPTIONS” learning.

internal/domain/model/organization.go (1)

20-34: Domain models for suggestions are well-scoped

Types map cleanly to API and infrastructure. No issues.

internal/domain/port/searcher.go (1)

30-32: SuggestOrganizations added — implementations updated

internal/domain/port/searcher.go contains the interface; matching implementations found in internal/infrastructure/clearbit/searcher.go, internal/infrastructure/mock/organization_searcher.go, and internal/service/organization_search.go.

cmd/service/providers.go (1)

165-200: Plumb CLEARBIT_AUTOCOMPLETE_BASE_URL through deployment config.
cmd/service/providers.go (lines 165–200) reads CLEARBIT_AUTOCOMPLETE_BASE_URL but a search returned no matches under charts/ — ensure Helm values.yaml and deployment templates (or other deployment manifests) export this env var to the service container.

design/query-svc.go (1)

130-167: LGTM — endpoint design is clear and consistent.

internal/service/organization_search.go (2)

65-92: LGTM — thin delegation with helpful telemetry.


21-23: Resolved — OrganizationSearcher implementers updated.
Search confirms SuggestOrganizations is declared in internal/domain/port/searcher.go and implemented in internal/infrastructure/clearbit/searcher.go and internal/infrastructure/mock/organization_searcher.go; internal/service/organization_search.go calls it.

internal/infrastructure/clearbit/client.go (2)

35-41: Call site looks fine once makeRequest is fixed.

No additional concerns here; the local model allocation pattern is correct.


55-61: Same as above; OK once makeRequest is fixed.

The domain path and query param assembly are fine.

- Added a check in the domainOrganizationSuggestionsToResponse function to return an empty suggestions result when the input is nil or has no suggestions.
- This enhancement improves the robustness of the response handling for organization suggestions.

Jira Ticket: https://linuxfoundation.atlassian.net/browse/LFXV2-199

Reviewed with [GitHub Copilot](https://github.com/features/copilot)

Signed-off-by: Mauricio Zanetti Salomao <mauriciozanetti86@gmail.com>
@mauriciozanettisalomao mauriciozanettisalomao merged commit 9f13a67 into linuxfoundation:main Sep 12, 2025
5 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.

3 participants