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

[BUG] When replacing a variable's value with object, it gets merged into an existing object #338

Open
jnv opened this issue Feb 24, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@jnv
Copy link
Contributor

jnv commented Feb 24, 2023

Provide a general summary of the issue in the Title above

I have a Comlink with roughly the following flow (based on linkedin's PublishPost use case):

set {
  content = input.link ? {article: { source: input.link, title: input.title || input.link }} : undefined
}
// ...something
set if (Array.isArray(images) && images.length > 0) {
  // set content (and override link if it was set); assume single image here
  content = {media: images[0]}
}
set if (Array.isArray(images) && images.length > 1) {
  content = {
    multiImage: {
      images: images,
    }
  }
}

Expected Behavior

I expect the content variable to always contain a new object with the single property; either {article}, {media}, or {multiImage}.

Current Behavior

It seems the existing object in the content variable gets merged with the new object instead, so I end up with {article, media}, {media, multiImage} and similar.

Possible Solution

I suspect the culprit might be in the interpreter; updating the stack is done with mergeVariables function which merges objects recursively:

this.stack = mergeVariables(this.stack, result.value as NonPrimitive);

Your Environment

  • Version used: OneSDK v2.3.0
  • Environment name and version: Node v18.12.1
  • Operating System and version: Fedora Linux 37
@jnv jnv added the bug Something isn't working label Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant