feat: strenghten the requirement around appName#11628
Open
gastonfournier wants to merge 3 commits intomainfrom
Open
feat: strenghten the requirement around appName#11628gastonfournier wants to merge 3 commits intomainfrom
gastonfournier wants to merge 3 commits intomainfrom
Conversation
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Contributor
API Changelog 7.5.1 vs. 7.5.1POST /api/client/register
POST /api/frontend/client/register
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens validation/handling of appName in client registration flows to prevent malformed client registrations from reaching the bulk upsert path that can trigger Knex’s “The query is empty” warning.
Changes:
- Enforce non-empty
appNamein OpenAPI schemas for client registration payloads (minLength: 1). - Update OpenAPI schema tests to use a non-empty
appName. - Add a defensive filter in
ClientInstanceService.bulkAdd()to skip registrations with falsyappName.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/lib/openapi/spec/frontend-api-client-schema.ts | Requires non-empty appName for the frontend client registration schema. |
| src/lib/openapi/spec/client-application-schema.ts | Requires non-empty appName for backend client registration schema used by /api/client/register. |
| src/lib/openapi/spec/client-application-schema.test.ts | Adjusts tests to reflect non-empty appName requirement. |
| src/lib/features/metrics/instance/instance-service.ts | Filters out registrations without a truthy appName before bulk upsert. |
Comments suppressed due to low confidence (1)
src/lib/openapi/spec/client-application-schema.test.ts:16
- The schema now requires non-empty
appName, but there’s no explicit test asserting thatappName: ""is rejected (the existing tests were changed to use a non-empty value). Please add a negative test case for emptyappNameto ensure the new constraint is enforced and doesn’t regress.
test('clientApplicationSchema required fields', () => {
const data: ClientApplicationSchema = {
appName: 'test-app',
interval: 0,
started: 0,
strategies: [''],
};
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
9
to
15
| appName: { | ||
| description: | ||
| 'An identifier for the app that uses the sdk, should be static across SDK restarts', | ||
| type: 'string', | ||
| minLength: 1, | ||
| example: 'example-app', | ||
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
About the changes
This PR fixes intermittent warnings like:
Failed to register clients The query is emptyThe issue was malformed client registrations reaching
bulkAdd(). In some cases, the set sent to DB upsert ended up effectively empty, which caused Knex to throw "The query is empty".What changed
ClientInstanceService.bulkAdd()to only process registrations with a truthyappName.This reduces warning noise and prevents invalid payloads from reaching bulk upsert paths.
Discussion points
appNamevalidation on register schemas, which aligns with existing runtime behavior using joi validation.