lichess-org / lila

♞ lichess.org: the forever free, adless and open source chess server ♞
https://lichess.org
GNU Affero General Public License v3.0
15.04k stars 2.23k forks source link

Study: fen changing when selecting chapter first move #15839

Open kraktus opened 1 month ago

kraktus commented 1 month ago

https://lichess.org/study/okfeqcVk/F6BCOKCz reported on discord https://discord.com/channels/280713822073913354/1267267010291568730/1267267010291568730

image

https://github.com/user-attachments/assets/5d1d1723-ec7a-4d26-95fe-8016344c540f

kraktus commented 1 month ago

exported the chapter, the error is also in the db

study-issue15839-chap.json

{
  "_id": "F6BCOKCz",
  "studyId": "okfeqcVk",
  "name": "Chapter 8",
  "setup": { "variant": 1, "orientation": true, "fromFen": true },
  "root": {
    "_": { "p": 0, "f": "7k/8/6p1/8/8/8/8/N6K w - - 0 1" },
    "#-": { "p": 1, "u": "a1c2", "s": "Nc2", "f": "7k/8/7p/8/8/8/2N5/7K b - - 1 1" },
    "#-bZ": { "p": 2, "u": "h8h7", "s": "Kh7", "f": "8/7k/7p/8/8/8/2N5/7K w - - 2 2" },
    "#-bZ-7": { "p": 3, "u": "c2e3", "s": "Ne3", "f": "8/7k/7p/8/8/4N3/8/7K b - - 3 2" },
    "#-bZ-7Zb": { "p": 4, "u": "h7h8", "s": "Kh8", "f": "7k/8/7p/8/8/4N3/8/7K w - - 4 3" },
    "#-bZ-7Zb7A": { "p": 5, "u": "e3g4", "s": "Ng4", "f": "7k/8/7p/8/6N1/8/8/7K b - - 5 3" },
    "#-bZ-7Zb7AbZ": { "p": 6, "u": "h8h7", "s": "Kh7", "f": "8/7k/7p/8/6N1/8/8/7K w - - 6 4" },
    "#-bZ-7Zb7AbZAR": { "p": 7, "u": "g4h6", "s": "Nxh6", "f": "8/7k/7N/8/8/8/8/7K b - - 0 4" }
  },
  "tags": [],
  "order": 10,
  "ownerId": "user",
  "createdAt": { "$date": "2024-06-01T01:00:00.000Z" }
}
lenguyenthanh commented 1 month ago

I can't creating the similar faulty study. We probably did something wrong but not sure what. Without a concrete way to reproduce it, it's quite hard to figure out the problem.

kraktus commented 1 month ago

Couldn't reproduce either for now, I guess there's some way to create a corrupted chapter.

fitztrev commented 1 month ago

Unsure if related yet but there's a console error on that page after I make the Nc2 move.

TypeError: Cannot read properties of undefined (reading 'toLowerCase')

https://github.com/lichess-org/lila/blob/e6fcf489241356b5b3995f43ee2fdc14ed6d526e/ui/chess/src/sanWriter.ts#L95

I can only repro by manually adding the above chapter export to my db. I don't get the console error locally though.