Skip to content

Comments

[LFXV2-1149] Add project_uid and project_uids query parameters to GET survey endpoint#7

Open
andrest50 wants to merge 3 commits intomainfrom
andrest50/get-survey-params
Open

[LFXV2-1149] Add project_uid and project_uids query parameters to GET survey endpoint#7
andrest50 wants to merge 3 commits intomainfrom
andrest50/get-survey-params

Conversation

@andrest50
Copy link
Contributor

@andrest50 andrest50 commented Feb 23, 2026

Summary

Adds support for optional project_uid and project_uids query parameters to the GET survey endpoint, enabling filtering of survey data by project context.

Ticket

LFXV2-1149

Changes

  • Added project_uid and project_uids query parameters to get_survey in Goa API design
  • Created GetSurveyParams struct in itx package to encapsulate query parameters
  • Updated domain SurveyClient interface to accept query params struct
  • Updated proxy client to build URL with query parameters and pass to ITX API
  • Implemented V2 to V1 ID mapping logic in service layer for both single and comma-delimited project UIDs
  • Created mapProjectUIDsV2ToV1 helper function using standard library strings package
  • Regenerated Goa code with new query parameters

Implementation Details

API Parameters

  • project_uid (optional): Single LFX Project UID (V2 format)
  • project_uids (optional): Comma-delimited list of LFX Project UIDs (V2 format)

Both parameters accept V2 UIDs which are mapped to V1 SFIDs before calling ITX, maintaining consistency with the V2 API design.

V2 to V1 ID Mapping

The service layer handles mapping:

  • Single project_uidproject_id (V1 SFID)
  • Multiple project_uidsproject_ids (comma-delimited V1 SFIDs)

Example Usage

# Single project
GET /surveys/b03cdbaf-53b1-4d47-bc04-dd7e459dd309?project_uid=qa1e8536-a985-4cf5-b981-a170927a1d11

# Multiple projects
GET /surveys/b03cdbaf-53b1-4d47-bc04-dd7e459dd309?project_uids=qa1e8536-a985-4cf5-b981-a170927a1d11,qa1e8536-a985-4cf5-b981-a170927a1d12

🤖 Generated with Claude Code

- Added project_uid and project_uids query parameters to get_survey in Goa API design
- Created GetSurveyParams struct in itx package to hold query parameters
- Updated domain interface to accept query params struct
- Updated proxy client to build URL with query parameters and pass to ITX
- Added V2 to V1 ID mapping logic in service layer for both single and comma-delimited project UIDs
- Created mapProjectUIDsV2ToV1 helper function using strings package
- Regenerated Goa code with new query parameters

The V2 API now accepts project_uid (V2 UID) which is mapped to project_id (V1 SFID)
before being passed to ITX, maintaining backward compatibility with ITX V1 IDs.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Andres Tobon <andrest2455@gmail.com>
Copilot AI review requested due to automatic review settings February 23, 2026 23:13
- Added project_uid and project_uids query parameters to Proxy API section
- Added project_id and project_ids query parameters to ITX API section
- Updated field mapping table to show V2 to V1 ID mapping for query parameters
- Documented that proxy accepts V2 UIDs and maps to V1 SFIDs for ITX

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Andres Tobon <andrest2455@gmail.com>
Copy link

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 PR adds optional project_uid and project_uids query parameters to the GET survey endpoint, enabling filtering of survey data by project context. The implementation handles V2 to V1 ID mapping automatically before calling the ITX API.

Changes:

  • Added optional query parameters project_uid and project_uids to the GET survey endpoint
  • Implemented V2 to V1 ID mapping in the service layer for both single and comma-delimited project UIDs
  • Updated the proxy client to build URLs with query parameters using proper URL encoding

Reviewed changes

Copilot reviewed 13 out of 15 changed files in this pull request and generated no comments.

Show a summary per file
File Description
api/survey/v1/design/survey.go Adds query parameter definitions to Goa API design
pkg/models/itx/models.go Introduces GetSurveyParams struct for query parameters
internal/service/survey_service.go Implements V2 to V1 ID mapping logic and parameter handling
internal/infrastructure/proxy/client.go Updates proxy client to build URLs with query parameters
internal/domain/proxy.go Updates SurveyClient interface signature
gen/* Regenerated Goa code with new query parameters
Comments suppressed due to low confidence (2)

internal/service/survey_service.go:168

  • The implementation allows both project_uid and project_uids to be provided simultaneously, but the API design states "Should not be combined with project_uid" in the description of project_uids. Consider adding validation to reject requests where both parameters are provided, or clarify the behavior when both are present.
	if p.ProjectUID != nil || p.ProjectUids != nil {
		queryParams = &itx.GetSurveyParams{}

		// Map single project_uid from V2 to V1
		if p.ProjectUID != nil && *p.ProjectUID != "" {
			projectV1, err := s.idMapper.MapProjectV2ToV1(ctx, *p.ProjectUID)
			if err != nil {
				s.logger.ErrorContext(ctx, "failed to map project_uid to V1",
					"project_uid", *p.ProjectUID,
					"error", err,
				)
				return nil, mapDomainError(err)
			}
			queryParams.ProjectID = &projectV1
			s.logger.DebugContext(ctx, "mapped project_uid",
				"project_v2_uid", *p.ProjectUID,
				"project_v1_sfid", projectV1,
			)
		}

		// Map project_uids from V2 to V1 (comma-delimited list)
		if p.ProjectUids != nil && *p.ProjectUids != "" {
			projectV1IDs, err := s.mapProjectUIDsV2ToV1(ctx, *p.ProjectUids)
			if err != nil {
				s.logger.ErrorContext(ctx, "failed to map project_uids to V1",
					"project_uids", *p.ProjectUids,
					"error", err,
				)
				return nil, mapDomainError(err)
			}
			queryParams.ProjectIDs = &projectV1IDs
			s.logger.DebugContext(ctx, "mapped project_uids",
				"project_v2_uids", *p.ProjectUids,
				"project_v1_sfids", projectV1IDs,
			)
		}
	}

internal/service/survey_service.go:766

  • If all comma-separated values in project_uids are empty or whitespace (e.g., " , , "), the function will return an empty string, which may result in sending project_ids= to the ITX API. Consider whether this is the intended behavior, or if you should return an error for this case. The same issue can occur with trailing commas like "uid1,uid2,".
// mapProjectUIDsV2ToV1 maps a comma-delimited list of project UIDs from V2 to V1
func (s *SurveyService) mapProjectUIDsV2ToV1(ctx context.Context, projectUIDs string) (string, error) {
	if projectUIDs == "" {
		return "", nil
	}

	// Split comma-delimited list and trim whitespace
	v2UIDs := strings.Split(projectUIDs, ",")
	v1IDs := make([]string, 0, len(v2UIDs))

	// Map each UID from V2 to V1
	for _, v2UID := range v2UIDs {
		trimmed := strings.TrimSpace(v2UID)
		if trimmed == "" {
			continue
		}
		v1ID, err := s.idMapper.MapProjectV2ToV1(ctx, trimmed)
		if err != nil {
			s.logger.ErrorContext(ctx, "failed to map project UID to V1",
				"project_v2_uid", trimmed,
				"error", err,
			)
			return "", err
		}
		v1IDs = append(v1IDs, v1ID)
	}

	// Join back into comma-delimited string
	return strings.Join(v1IDs, ","), nil

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Renamed queryParams to params in GetSurvey method for consistency
- Bumped Helm chart version from 0.1.2 to 0.1.3

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Andres Tobon <andrest2455@gmail.com>
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