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] monday.storage.instance.setItem(someKey, someVal) silently fails when someVal contains a newline character #57

Closed
dvdsmpsn opened this issue May 25, 2022 · 1 comment

Comments

@dvdsmpsn
Copy link

dvdsmpsn commented May 25, 2022

Describe the bug

monday.storage.instance.setItem(someKey, someVal) silently fails when someVal contains a newline character

Steps to reproduce

  1. Embed the SDK in an app
  2. Call monday.storage.instance.setItem(someKey, someVal) where someVal has a newline character
  3. The request silently fails

Example 1: Expected behavior

Without a newline character, everything is fine.

const monday = mondaySdk();

const someKey = "someKey";
const someVal = "Lorem Ipsum 123";
monday.storage.instance.setItem(someKey, someVal).then((res) => {
  console.log(res);
  // --> {method: 'storage', type: undefined, data: {success: true, version: 'edc92'}, requestId: 'en3u9u96f', errorMessage: undefined}
  
  monday.storage.instance.getItem(someKey).then((res) => {
    console.log(res.data.value); 
    // --> Lorem Ipsum 123
    
  });
});

Example 2: Actual behavior with new line character

This now fails silently because of a new line character, but reports that it has succeeded.

const monday = mondaySdk();

const someKey = "someKey";
const someVal = "Lorem Ipsum 123\n\nxxxx";
monday.storage.instance.setItem(someKey, someVal).then((res) => {
  console.log(res);
  // --> {method: 'storage', type: undefined, data: {success: true, version: 'edc92'}, requestId: 'en3u9u96f', errorMessage: undefined}
  
  monday.storage.instance.getItem(someKey).then((res) => {
    console.log(res.data.value); // --> NULL
  });
});

Example 3: A workaround

Dodgy workaround to get around the failure from the new line character

const monday = mondaySdk();
const someKey = "someKey";
const someVal = "Lorem Ipsum 123\n\nxxxx";
const newLine = "[NEWLINE]";
monday.storage.instance.setItem(
  someKey, 
  someVal.replaceAll("\n", newLine)
).then((res) => {
  console.log(res);
  // --> {method: 'storage', type: undefined, data: {success: true, version: 'edc92'}, requestId: 'en3u9u96f', errorMessage: undefined}
  
  monday.storage.instance.getItem(someKey).then((res) => {
    console.log(
      res.data.value
    ); // --> Lorem Ipsum 123[NEWLINE][NEWLINE]xxxx
    
    console.log(
      res.data.value
        .replaceAll(newLine, "\n")
    ); // --> Lorem Ipsum 123\n\nxxxx
  });
});

Context and environment
What capabilities were you trying to use?
-monday.storage.instance.setItem(someKey, someVal) where someVal has a newline character

On which browser/mobile device?

  • any desktop browser

What app was involved?

  • my own developer app

Additional information

@dvdsmpsn dvdsmpsn changed the title [Bug] [Bug] monday.storage.instance.setItem(someKey, someVal) silently fails when someVal has a newline character May 25, 2022
@dvdsmpsn dvdsmpsn changed the title [Bug] monday.storage.instance.setItem(someKey, someVal) silently fails when someVal has a newline character [Bug] monday.storage.instance.setItem(someKey, someVal) silently fails when someVal contains a newline character May 25, 2022
@gregra81
Copy link
Collaborator

Hey @dvdsmpsn, I know this is coming almost two years later, but I'm doing some hygiene in these issues. From checking with the team, this issue has already been resolved, so I'm closing it for now. If you have a new issue around the storage methods, feel free to open a new issue

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

No branches or pull requests

2 participants