Skip to content

Refactor API endpoint construction and add ID validation#85

Merged
arslanbekov merged 1 commit intomainfrom
fix/url-path-injection
Jan 27, 2026
Merged

Refactor API endpoint construction and add ID validation#85
arslanbekov merged 1 commit intomainfrom
fix/url-path-injection

Conversation

@arslanbekov
Copy link
Member

Description

  • Replaced direct string formatting for API endpoints with a new buildURL function for consistency and readability across multiple services.
  • Introduced validateID checks in various service methods to ensure that IDs are valid before making API requests, enhancing error handling and robustness.
  • Updated methods in HostApplicationsService, HostConnectorsService, HostIPServicesService, HostRoutesService, HostsService, LocationContextsService, NetworkApplicationsService, NetworkConnectorsService, NetworkIPServicesService, NetworksService, RoutesService, UserGroupsService, and UsersService to reflect these changes.

Signed-off-by: Denis Arslanbekov <denis@arslanbekov.com>
Copy link
Contributor

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 standardizes how CloudConnexa API endpoints are constructed and adds basic ID validation to fail fast on empty identifiers before making requests.

Changes:

  • Introduces buildURL for consistent endpoint construction with escaped path segments.
  • Adds validateID (and ErrEmptyID) and applies it across multiple service methods that require IDs.
  • Updates route/connector pagination endpoints to use url.Values for safer query-string construction.

Reviewed changes

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

Show a summary per file
File Description
cloudconnexa/cloudconnexa.go Adds buildURL helper (with path escaping) and validateID helper.
cloudconnexa/errors.go Introduces ErrEmptyID used by validateID.
cloudconnexa/cloudconnexa_test.go Adds unit tests for buildURL and validateID.
cloudconnexa/users.go Uses buildURL and adds validateID checks for user ID-based operations.
cloudconnexa/user_groups.go Uses buildURL and adds validateID checks for user-group ID operations.
cloudconnexa/networks.go Uses buildURL and adds validateID checks for network ID operations.
cloudconnexa/routes.go Adds validateID checks and uses url.Values for query params; uses buildURL for path-based endpoints.
cloudconnexa/hosts.go Uses buildURL and adds validateID checks for host ID operations.
cloudconnexa/host_routes.go Adds validateID checks; uses url.Values for query params; uses buildURL for ID endpoints.
cloudconnexa/host_connectors.go Adds validateID checks; uses url.Values for query params; uses buildURL for ID endpoints.
cloudconnexa/network_connectors.go Adds validateID checks; uses url.Values for query params; uses buildURL for ID endpoints.
cloudconnexa/host_ip_services.go Uses buildURL and adds validateID checks for IP service ID operations.
cloudconnexa/network_ip_services.go Uses buildURL and adds validateID checks for IP service ID operations.
cloudconnexa/host_applications.go Uses buildURL and adds validateID checks for application ID operations.
cloudconnexa/network_applications.go Uses buildURL and adds validateID checks for application ID operations.
cloudconnexa/location_contexts.go Uses buildURL and adds validateID checks for location-context ID operations.
cloudconnexa/dns_records.go Uses buildURL and adds validateID checks for DNS record ID operations.
cloudconnexa/devices.go Uses buildURL and adds validateID checks for device ID operations.
cloudconnexa/access_groups.go Uses buildURL and adds validateID checks for access-group ID operations.

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

@arslanbekov arslanbekov merged commit 7fe7ed5 into main Jan 27, 2026
14 checks passed
@arslanbekov arslanbekov deleted the fix/url-path-injection branch January 27, 2026 01:48
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.

1 participant

Comments