product-os / jellyfish

The Jellyfish Project
https://jel.ly.fish/
GNU Affero General Public License v3.0
15 stars 3 forks source link

Message loses formatting 3 seconds after sending #1660

Closed pdcastro closed 5 years ago

pdcastro commented 5 years ago

Steps to reproduce:

Not knowing what goes on under the hood of Jellyfish, I will hazard a guesswork theory: Jellyfish sends the message to Flowdock, which forward to Front, which feeds it back to Jellyfish. Jellyfish then goes "aha, I already had this message, won't create a new one, but should be safe to overwrite it". BUT Front (or Flowdock) discards / messes with the formatting, and so Jellyfish replaces the good formatting with the messed up one. The solution is then to avoid overwriting messages in this situation.

LucianBuzzo commented 5 years ago

Related discussion in FD https://www.flowdock.com/app/rulemotion/p-cyclops/threads/szpJz2zqWvofXnOYdXoGSPhnPvc

TLDR The front API mangles backticks and we're not sure how to work around this issue

pdcastro commented 5 years ago

The front API mangles backticks and we're not sure how to work around this issue

But the message was originally written in JF, not in Front, so why overwrite the good JF message with a bad Front message? Discard the Front message and keep the original message...

LucianBuzzo commented 5 years ago

@pdcastro "We're not sure" means that we don't have a working solution yet. Fixing sync issues is very high on the priority list for the Jellyfish team.

jviotti commented 5 years ago

@pdcastro The problem is that Front essentially mutates the message after it is inserted, and a new web hook is emitted, and then Jellyfish interprets it as an edit, and (rightfully) mutates it in Jellyfish as well. There might be clever ways to "ignore" that incorrect edit, but we'd have to be super careful to make sure we also don't swallow real edits.

pdcastro commented 5 years ago

I see, JF is trying to accept edits, thanks for the explanation! JF should be able to tell (even if a code/model change is required) whether a message was originally created through JF. In this case, if a message was written in JF, perhaps it's reasonable to deny/ignore edits coming from Front. It's already the case that Front edits are not reflected in Flowdock, for example.

jviotti commented 5 years ago

@pdcastro Yeah, definitely. We've seen that the Front UI uses a different (undocumented) endpoint for posting messages, and that one doesn't seem to mess up the back ticks, so it might be also worth trying that first. I'll do some more investigation on this during the week and see how it goes! Thanks a lot for reporting!

jviotti commented 5 years ago

@pdcastro @LucianBuzzo I think I managed to fix this, and I have not been able to reproduce in production (at least on a whisper). I'll optimistically close it, but don't hesitate on re-opening if I ended up being wrong :P

pdcastro commented 5 years ago

I've just reproduced it with a message sent to a customer in this thread: https://jel.ly.fish/#/1168e5a2-ad91-4233-914e-f37619c69101

The original message I typed had this markdown:

=========================================

is there a way to see exactly what I can specify?

Pablo already shared one Docker Hub URL, here's another one, check how the Docker Hub URL matches the GitHub URL:

=========================================

A few seconds after sending the message, the quote indentation, the italics and the bullet points were lost.

Message JSON (after formatting was lost):

{
  "id": "7109553f-3e7b-4813-a9ea-2b8721869983",
  "data": {
    "actor": "629bb175-9271-4781-a952-1656bf20609d",
    "origin": "external-event-9d0b23cd-be49-472c-b5d2-ff4456c976b4",
    "target": "1168e5a2-ad91-4233-914e-f37619c69101",
    "mirrors": [
      "https://api2.frontapp.com/messages/msg_2izarpn"
    ],
    "payload": {
      "message": "is there a way to see exactly what I can specify?\n\nPablo already shared one Docker Hub URL, here's another one, check how the Docker Hub URL matches the GitHub URL:\n\nhttps://hub.docker.com/r/balenalib/armv7hf-debian-node/tags\n\nhttps://github.com/balena-io-library/base-images/tree/master/balena-base-images/node/armv7hf/debian/stretch",
      "alertsUser": [],
      "mentionsUser": []
    },
    "timestamp": "2019-04-05T20:27:08.030Z",
    "translateDate": "2019-04-05T20:27:08.030Z"
  },
  "name": null,
  "slug": "message-2d093b32-6034-43b4-bdbb-80495f370f34",
  "tags": [],
  "type": "message",
  "links": {
    "is attached to": [
      {
        "id": "1168e5a2-ad91-4233-914e-f37619c69101",
        "slug": "support-thread-front-cnv-1bgs94z",
        "type": "support-thread",
        "$link": "40346318-8ad6-4ac2-9670-a38f1857a244"
      }
    ],
    "has attached element": [
      {
        "id": "5625a5bf-c80e-4def-8666-b33265f6195b",
        "slug": "update-b92690d1-a2bf-4191-9544-e4bcfeb32c6e",
        "type": "update",
        "$link": "84f1934d-626a-4f25-8846-8a077753c676"
      },
      {
        "id": "7863119f-3629-4a56-b0ee-e268af695c58",
        "slug": "update-caaf3ae7-2cff-4a52-8f08-527ccfdb9677",
        "type": "update",
        "$link": "b1dd6da3-3ef5-48f8-a053-834e19f258cf"
      }
    ]
  },
  "active": true,
  "markers": [],
  "version": "1.0.0",
  "requires": [],
  "linked_at": {
    "is attached to": "2019-04-05T20:27:08.400Z",
    "has attached element": "2019-04-05T20:27:15.896Z"
  },
  "created_at": "2019-04-05T20:27:06.813Z",
  "updated_at": "2019-04-05T20:27:15.626Z",
  "capabilities": []
}
pdcastro commented 5 years ago

In this thread too, again in a message to the customer: https://jel.ly.fish/#/3d3b5771-1c34-4045-bf78-14fc41bc5a36

Edit: actually seems to happen in every message I send to customers.

LucianBuzzo commented 5 years ago

I'm seeing the same issue here https://jel.ly.fish/#/d9e9c3b6-6c6f-4562-a5f4-ddde51c9a0b6

LucianBuzzo commented 5 years ago

It seems to not happen with whispers - take a look at https://jel.ly.fish/#/d10d2b38-bb74-4b05-9839-0ed8723e0020 I posted a whisper that was formatted fine, and the message I posted afterwards is corrupted

LucianBuzzo commented 5 years ago

Another occurrence here https://jel.ly.fish/#/view~5b454891-273c-4c0e-bda3-4e191ae0b426/support-thread~ad2be397-0890-4012-b45d-d0fbc418a114

LucianBuzzo commented 5 years ago

Closing this issue in favour of https://github.com/balena-io/jellyfish/issues/1772 as it better describes the current mangling bug

jviotti commented 5 years ago

The message on the last occurrence that JF sent was:

Hello, thanks for confirming. Pip has always had obscure issues on emulated builders but this is the first time to hear about issues with native ARM builders, so this is interesting. I've created an internal issue to track this.\n\nI think the full `pip install` logs would be useful -- can you try running pip with `-verbose` flag?\n\nI would also suspect that dual Python 2 and 3 installation might have something to do with this, though this wouldn't explain why it only happens on native ARM builders.

Let me see if I can reproduce by posting the same thing

jviotti commented 5 years ago

@LucianBuzzo God, I just realised I set the plain text fix in the object that is passed to the logger and not to the actual Front SDK 🤦‍♂️