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.61k stars 2.28k forks source link

Reusing saved PGN imports can cause issues #10818

Closed dlbbld closed 2 years ago

dlbbld commented 2 years ago

Reusing saved PGN imports can cause issues for bug fixes.

For example, when some logic in the import is wrong and fixed, the user importing the same file again, will not see the fix. He will see the result of before the fix because the import is saved.

One fix recently concerning the import was #10519 and one just now was #10816:

For example, importing the below in Tools / Import game:

1.e4 c5 2.Nf3 Nc6 3.d4
cxd4

still results in 1.e4 c5 2.Nf3 Nc6 3.d4 as I still have one old import from yesterday (https://lichess.org/CxeYSWGr).

Only when amending the PGN by adding some tags for example, so it creates a new import entry, the result is correct

[Random "Replace me with a random string"]
1.e4 c5 2.Nf3 Nc6 3.d4
cxd4

Results correctly in 1.e4 c5 2.Nf3 Nc6 3.d4 cxd4

I suggest for a start to compare the result of the import with the saved import and when the result is different, create a new import, to avoid such problems.

dlbbld commented 2 years ago

Another example. I import the following game: https://www.chessgames.com/perl/nph-chesspgn?text=1&gid=2072187

[Event "Marianske Lazne Open"]
[Site "Marianske Lazne CZE"]
[Date "2013.01.19"]
[EventDate "?"]
[Round "1"]
[Result "1-0"]
[White "Alexandr Granovskiy"]
[Black "Ursula Grochocinska"]
[ECO "B06"]
[WhiteElo "?"]
[BlackElo "?"]
[Source "http://chessexpress.blogspot.com/2013/02/"]
[PlyCount "154"]

1. d4 d6 2. e4 g6 3. Nc3 Bg7 4. Be3 Nf6 5. Qd2 a6 6. Bh6 O-O 7. Bxg7 Kxg7 8. O-O-O b5 9. f3 Bb7 10. g4 Nbd7 11. Nge2 c5 12. dxc5 Nxc5 13. Ng3 Rc8 14. g5 Nfd7 15. h4 Ne5 16. Bh3 Rc6 17. f4 Ncd3+ 18. Kb1 Nxb2 19. fxe5 Nxd1 20. Qxd1 Qa5 21. Nce2 dxe5 22. Qd5 Qc7 23. Qb3 Rc4 24. h5 a5 25. a3 a4 26. Qf3 Rxc2 27. hxg6 fxg6 28. Bf5 Qc4 29. Rxh7+ Kg8 30. Be6+ Qxe6 31. Rh8+ Kxh8 32. Qxf8+ Kh7 33. Kxc2 Qa2+ 34. Kd1 Qxa3 35. Qf7+ Kh8 36. Qf8+ Kh7 37. Qf7+ Kh8 38. Qxg6 Qd6+ 39. Qxd6 exd6 40. Nc3 Bc6 41. Nd5 Kh7 42. Ne7 Be8 43. Ngf5 Bh5+ 44. Kc1 b4 45. Nxd6 a3 46. Kc2 Bd1+ 47. Kb1 b3 48. g6+ Kh6 49. Ndf5+ Kh5 50. g7 Bc2+ 51. Kc1 Bxe4 52. Ng3+ Kh6 53. g8=N+ Kg5 54. Nxe4+ Kf4 55. Ngf6 Ke3 56. Nc5 b2+ 57. Kc2 Kd4 58. Nce4 Kc4 59. Ned5 Kb5 60. Ndc3+ Kb4 61. Na2+ Kc4 62. Nec3 Kd4 63. Nb1 e4 64. Nxa3 e3 65. Nb1 Ke5 66. Nd7+ Kf4 67. Kd1 Ke4 68. Ke2 Kd4 69. Nac3 Kc4 70. Ne5+ Kb3 71. Kd3 e2 72. Nxe2 Ka2 73. Kc2 Ka1 74. Nc4 Ka2 75. Nbd2 Ka1 76. Nb3+ Ka2 77. Nc3# 1-0

The import says it was imported six hours ago, and the result is:

[Event "Marianske Lazne Open"]
[Site "https://lichess.org/xjMSAOET"]
[Date "2013.01.19"]
[Round "1"]
[White "?"]
[Black "?"]
[Result "*"]
[WhiteElo "?"]
[BlackElo "?"]
[Variant "Standard"]
[TimeControl "-"]
[ECO "?"]
[Opening "?"]
[Termination "Unterminated"]

*

Something at the time went wrong. Now, though the import logic is corrected, I still see the old wrong imported data resulting from the import. Very inconvenient. The trick is to add some other tag, so a new import entry is created, but users unaware of this problem might face corrupt PGN files for this behaviour.

ornicar commented 2 years ago

I deleted them

dlbbld commented 2 years ago

Deleting a few imports (as I understand) does not approach the root of the problem.

For example in #10520 also something in the import was fixed.

When importing the below game, the result is still given as "Fifty moves.. Draw " instead of White Win.

Because there is still an old import. You can impossible identify all wrong imports. As such I suggest checking in the import if something was changed and if so creating a new import to avoid older bugs affecting imports.

[Event "World Blitz Championship"]
[Site "Dubai UAE"]
[Date "2014.06.19"]
[EventDate "2014.06.19"]
[Round "7.1"]
[Result "1-0"]
[White "Magnus Carlsen"]
[Black "Le Quang Liem"]
[ECO "D73"]
[WhiteElo "2881"]
[BlackElo "2712"]

1. d4 Nf6 2. Nf3 g6 3. g3 Bg7 4. Bg2 d5 5. c4 c6 6. cxd5 cxd5
7. Ne5 O-O 8. Nc3 e6 9. O-O Nfd7 10. Nf3 Nf6 11. Bf4 Nc6
12. Rc1 Bd7 13. Qd2 Rc8 14. Ne5 Qe7 15. Rfd1 Rfd8 16. Bg5 Qf8
17. h4 h6 18. Bxf6 Bxf6 19. f4 h5 20. e3 Be8 21. Bf3 Ne7
22. Kf2 Nf5 23. Ne2 Qd6 24. Qa5 Qb6 25. Qxb6 axb6 26. Rxc8
Rxc8 27. Rc1 Ra8 28. a3 Nd6 29. Nc3 Kf8 30. e4 dxe4 31. Nxe4
Bxe5 32. dxe5 Nxe4+ 33. Bxe4 Bc6 34. Ke3 Ke7 35. Bd3 Ra5
36. Rc3 Rc5 37. Rb3 b5 38. Rc3 Rxc3 39. bxc3 Kd7 40. Kd4 b6
41. Ke3 Kc7 42. Kd2 Bd7 43. Ke3 Kc6 44. Kd4 Kc7 45. Be2 Bc6
46. g4 hxg4 47. Bxg4 Kd7 48. Be2 Kc7 49. h5 gxh5 50. Bxh5 Be8
51. f5 Kd7 52. f6 Kc7 53. Bf3 Bc6 54. Be2 Be8 55. Bd1 Bd7
56. Bb3 Be8 57. Ke4 Kd8 58. Kf4 Bd7 59. Bd1 Bc6 60. Be2 Bd7
61. Bd3 Bc6 62. Ke3 Kc7 63. Kd2 Be8 64. Be4 Bc6 65. Bc2 Be8
66. Kd3 Kc6 67. Kd4 Kc7 68. Ke4 Bc6+ 69. Kf4 Kd8 70. Bb3 Bd7
71. Kg5 Ke8 72. Kh6 Kf8 73. Bc2 Bc6 74. Kh7 Bd5 75. Bd3 Bc6
76. Be2 Be4+ 77. Kh8 Bc6 78. Bf1 Bd7 79. Bg2 Be8 80. Bb7 Bd7
81. Ba6 Bc6 82. Bc8 Be4 83. Bd7 Bd3 84. Bc6 Bc4 85. Kh7 Bd3+
86. Kh6 Kg8 87. Kg5 Bc4 88. Kf4 Kh7 89. Kg5 Kg8 90. Bd7 Kh7
91. Be8 Kg8 92. Kf4 Kf8 93. Bc6 Kg8 94. Ke4 Kh7 95. Kd4 Bf1
96. Be8 Kg6 97. Ke3 Kf5 98. Kd4 Kg6 99. Ke4 Bc4 100. Kf4 Bf1
101. Bc6 Kh6 102. Bb7 Bc4 103. Ba6 1-0
dlbbld commented 2 years ago

In my opinion, the above observation justifies reopening the issue.

OT, not saving the imports :-) would resolve the problem.