Skip to content
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

Recent reordering of marshall function overload signatures returns incorrect signature #4901

Closed
3 tasks done
jeremydaly opened this issue Jul 1, 2023 · 3 comments · Fixed by #4909
Closed
3 tasks done
Assignees
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@jeremydaly
Copy link

Checkboxes for prior research

Describe the bug

The change made in commit cb4a0e3 incorrectly reorders the overload that returns AttributeValue[] type instead of Record<string, AttributeValue> when passing in a JavaScript object to be marshalled.

SDK version number

@aws-sdk/util-dynamodb@3.363.0

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v18.15.0

Reproduction Steps

import { marshall } from '@aws-sdk/util-dynamodb';

const data = {
  pk: 'abc',
  sk: 'xyz'
}

const ExpressionAttributeValues = marshall(data);

Observed Behavior

The code above assigns ExpressionAttributeValues a type of AttributeValue[].

Expected Behavior

ExpressionAttributeValues should be assigned a type of Record<string, AttributeValue>.

Possible Solution

Swap the two overload signatures so that the one returning Record<string, AttributeValue> takes precedence. Otherwise this breaks a lot of existing implementations.

Additional Information/Context

No response

@jeremydaly jeremydaly added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 1, 2023
@RanVaknin RanVaknin self-assigned this Jul 3, 2023
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 18, 2023
@kuhe
Copy link
Contributor

kuhe commented Jun 13, 2024

In review, I don't see how this issue was possible.

The resolution order was

export function marshall<L extends NativeAttributeValue[]>(data: L, options?: marshallOptions): AttributeValue[];
export function marshall<M extends { [K in keyof M]: NativeAttributeValue }>(
  data: M,
  options?: marshallOptions
): Record<string, AttributeValue>;

and object literals do not match XYZ[] (array) types.

@kuhe
Copy link
Contributor

kuhe commented Jun 13, 2024

it's possible the object was typed as any in code not shown, which matches array signatures

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants