[Customer Entity] Rename snclient package and align IntegrationService config field names with ServiceNow prefix - #857
Conversation
…config fields to ServiceNow-prefixed names
📝 WalkthroughWalkthroughReplaces the ChangesServiceNow Integration Service Client Migration
Sequence DiagramsequenceDiagram
participant NewRouter
participant integrationservice.New
participant accessToken as Client.accessToken
participant TokenEndpoint
participant IntegrationServiceAPI
participant SNService as sn_*_service
NewRouter->>integrationservice.New: New(baseURL, ClientCredentialsConfig)
integrationservice.New-->>NewRouter: *Client
NewRouter->>SNService: NewServiceNow*Service(*Client, ...)
Note over SNService,IntegrationServiceAPI: At request time
SNService->>accessToken: accessToken(ctx)
accessToken->>TokenEndpoint: POST client-credentials grant
TokenEndpoint-->>accessToken: access_token + expires_in
accessToken-->>SNService: bearer token
SNService->>IntegrationServiceAPI: GET/POST with Authorization + x-user-id-token
IntegrationServiceAPI-->>SNService: HTTP response → json.RawMessage or apierror
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
entity-service/internal/servicenow-integration-service/client.go (1)
94-213: ⚡ Quick winStandardize error prefixes to
integrationserviceacross the new client.The migrated package still emits
"snclient:"in multiple error paths, which makes logs and alerts misleading post-migration.Suggested cleanup
+const errPrefix = "integrationservice" ... - return "", fmt.Errorf("snclient: build token request: %w", err) + return "", fmt.Errorf("%s: build token request: %w", errPrefix, err) ... - return "", fmt.Errorf("snclient: read token response: %w", err) + return "", fmt.Errorf("%s: read token response: %w", errPrefix, err) ... - return "", fmt.Errorf("snclient: parse token response: %w", err) + return "", fmt.Errorf("%s: parse token response: %w", errPrefix, err) ... - return nil, fmt.Errorf("snclient: build request: %w", err) + return nil, fmt.Errorf("%s: build request: %w", errPrefix, err)Apply the same replacement pattern to the remaining
"snclient:"occurrences in this file.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@entity-service/internal/servicenow-integration-service/client.go` around lines 94 - 213, Replace all error message prefixes from "snclient:" to "integrationservice" throughout the client code to maintain consistency post-migration. Update the error prefix in the accessToken method (including "snclient: build token request", "snclient: read token response", "snclient: parse token response", and "snclient: token endpoint returned empty access_token"), in the Get method ("snclient: build request"), in the Post method ("snclient: build request" and "snclient: marshal request"), and in the do method ("snclient: %s: %v", "snclient: read response body", and "snclient: %s: unexpected status"). This ensures all error logs emit the "integrationservice" prefix consistently across all API operations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@entity-service/internal/config/config.go`:
- Around line 96-109: The Validate() method is missing a required validation
check for the ServiceNow scopes configuration. Add a validation check for
ServiceNowIntegrationServiceScopes in the same conditional block where you check
DataSourceServiceNow. Follow the same pattern as the existing four ServiceNow
field validations by checking if ServiceNowIntegrationServiceScopes is empty and
returning an appropriate error message indicating that
SERVICENOW_INTEGRATION_SERVICE_SCOPES is required when DATA_SOURCE=servicenow.
---
Nitpick comments:
In `@entity-service/internal/servicenow-integration-service/client.go`:
- Around line 94-213: Replace all error message prefixes from "snclient:" to
"integrationservice" throughout the client code to maintain consistency
post-migration. Update the error prefix in the accessToken method (including
"snclient: build token request", "snclient: read token response", "snclient:
parse token response", and "snclient: token endpoint returned empty
access_token"), in the Get method ("snclient: build request"), in the Post
method ("snclient: build request" and "snclient: marshal request"), and in the
do method ("snclient: %s: %v", "snclient: read response body", and "snclient:
%s: unexpected status"). This ensures all error logs emit the
"integrationservice" prefix consistently across all API operations.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e74dd980-7612-4ebe-b45e-d0504faed99f
📒 Files selected for processing (8)
entity-service/.env.exampleentity-service/internal/config/config.goentity-service/internal/server/routes.goentity-service/internal/service/sn_case_service.goentity-service/internal/service/sn_deployment_service.goentity-service/internal/service/sn_project_service.goentity-service/internal/servicenow-integration-service/client.goentity-service/internal/snclient/client.go
💤 Files with no reviewable changes (1)
- entity-service/internal/snclient/client.go
Summary
internal/snclientpackage directory tointernal/servicenow-integration-servicefor clarity; addedintegrationserviceimport alias in all consuming files since Go identifiers cannot contain hyphensIntegrationService*fields inconfig.ConfigtoServiceNowIntegrationService*(e.g.IntegrationServiceBaseURL→ServiceNowIntegrationServiceBaseURL) to make the origin of these credentials unambiguous at the call siteTest plan
go build ./...passes with no errorsDATA_SOURCE=servicenowstartup with allSERVICENOW_INTEGRATION_SERVICE_*env vars set boots without config validation errorsDATA_SOURCE=postgresstartup is unaffectedSummary by CodeRabbit
Release Notes
Configuration
Refactor