Skip to content

fix: add proper checks for Hierarchical PartionKeys #1283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

manekinekko
Copy link
Collaborator

@manekinekko manekinekko commented Jun 10, 2025

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #1165

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

paths: [`/${partitionKey}`],
};
}
else if (typeof partitionKey === 'object') {

Choose a reason for hiding this comment

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

I think the partition key might be an array, which will still resolve to object and in this case will work just fine. Looks good to me :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I understand the confusion here, but partitionKey here represents actually entityDescriptor.partitionKey object, not the partition keys values (paths).

@manekinekko manekinekko requested a review from Copilot July 3, 2025 07:41
Copy link

@Copilot 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 enhances partition key handling, broadens dependency compatibility, and cleans up related code.

  • Adds runtime checks in provider to distinguish string vs. object partitionKey definitions.
  • Updates package.json to support NestJS v10 and v11 and loosen Azurite version.
  • Removes a no-op test hook and tweaks core module destructuring to adjust forwarded SDK options.

Reviewed Changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
sample/cosmos-db/src/event/event.entity.ts Minor formatting (trailing commas/semicolons) to align syntax.
package.json Expanded version ranges for @nestjs/* and azurite dependencies.
lib/cosmos-db/cosmos-db.providers.ts Added type guards and error handling for partitionKey definitions.
lib/cosmos-db/cosmos-db.decorators.spec.ts Removed commented mock and replaced with an empty beforeEach hook.
lib/cosmos-db/cosmos-db-core.module.ts Excluded connectionName from destructuring to change SDK parameters.
Files not reviewed (1)
  • sample/cosmos-db/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)

lib/cosmos-db/cosmos-db.decorators.spec.ts:5

  • [nitpick] This empty beforeEach block is redundant and can be removed to streamline the tests.
  beforeEach(() => {});

@@ -47,7 +47,7 @@ export class AzureCosmosDbCoreModule {
const connectionProvider = {
provide: cosmosConnectionName,
useFactory: async (cosmosModuleOptions: AzureCosmosDbOptions): Promise<any> => {
const { dbName, retryAttempts, retryDelay, connectionName, ...cosmosOptions } = cosmosModuleOptions;
const { dbName, retryAttempts, retryDelay, ...cosmosOptions } = cosmosModuleOptions;
Copy link
Preview

Copilot AI Jul 3, 2025

Choose a reason for hiding this comment

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

connectionName is no longer excluded and will be spread into cosmosOptions, potentially passing an unsupported option to the Azure SDK. Re-introduce connectionName in the destructuring exclusion or explicitly delete it from cosmosOptions.

Suggested change
const { dbName, retryAttempts, retryDelay, ...cosmosOptions } = cosmosModuleOptions;
const { dbName, retryAttempts, retryDelay, connectionName, ...cosmosOptions } = cosmosModuleOptions;

Copilot uses AI. Check for mistakes.

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