FAILURE MAP
← Case archive

FA-82626 / Chess move legality / Open access

Overlong UCI strings pass validation · case 01

"e7e8qq" is treated as a promotion with suffix "qq".

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Only a lower length bound is enforced.

VERIFIED REPAIR

A UCI move has exactly 4 or 5 characters.

Unsuccessful approach: Enforcing only the upper bound lets "e2e" slice into a malformed destination.

Case contract

Input: {"board", "uci": move string}. Return "ok" or a reason: "syntax" (length not 4-5, squares outside a1-h8, or from equals to), "no piece" (origin empty), "promotion required" (a white pawn reaching rank 8 or black pawn reaching rank 1 without a suffix), "unexpected promotion" (suffix on any other move), "bad promotion" (suffix not one of q, r, b, n).

Why this case matters

Engines and servers exchange moves in this long algebraic format.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    u=x['uci']; b=x['board']
    if len(u)<4: return 'syntax'
    fr,to,promo=u[:2],u[2:4],u[4:]
    for s in (fr,to):
        if s[0] not in 'abcdefgh' or s[1] not in '12345678': return 'syntax'
    if fr==to: return 'syntax'
    p=b.get(fr)
    if p is None: return 'no piece'
    last=(p=='P' and to[1]=='8') or (p=='p' and to[1]=='1')
    if last and not promo: return 'promotion required'
    if promo and not last: return 'unexpected promotion'
    if promo and promo not in 'qrbn': return 'bad promotion'
    return 'ok'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('simple move', {'board': {'e2': 'P'}, 'uci': 'e2e4'}, 'ok'),
  ('rank nine', {'board': {'e2': 'P'}, 'uci': 'e2e9'}, 'syntax'),
  ('rank zero', {'board': {'e2': 'P'}, 'uci': 'e2e0'}, 'syntax'),
  ('white promotion', {'board': {'e7': 'P'}, 'uci': 'e7e8q'}, 'ok'),
  ('white needs promotion', {'board': {'e7': 'P'}, 'uci': 'e7e8'}, 'promotion required'),
  ('black needs promotion', {'board': {'b2': 'p'}, 'uci': 'b2b1'}, 'promotion required'),
  ('too long', {'board': {'e7': 'P'}, 'uci': 'e7e8qq'}, 'syntax'),
  ('too short', {'board': {'e2': 'P'}, 'uci': 'e2e'}, 'syntax')],
 [('white promotion', {'board': {'e7': 'P'}, 'uci': 'e7e8q'}, 'ok'),
  ('white needs promotion', {'board': {'e7': 'P'}, 'uci': 'e7e8'}, 'promotion required'),
  ('black needs promotion', {'board': {'b2': 'p'}, 'uci': 'b2b1'}, 'promotion required'),
  ('black promotes knight', {'board': {'b2': 'p'}, 'uci': 'b2a1n'}, 'ok'),
  ('rook reaches last rank', {'board': {'a1': 'R'}, 'uci': 'a1a8'}, 'ok'),
  ('king promotion', {'board': {'e7': 'P'}, 'uci': 'e7e8k'}, 'bad promotion'),
  ('too long', {'board': {'e7': 'P'}, 'uci': 'e7e8qq'}, 'syntax'),
  ('too short', {'board': {'e2': 'P'}, 'uci': 'e2e'}, 'syntax')],
 [('black promotes knight', {'board': {'b2': 'p'}, 'uci': 'b2a1n'}, 'ok'),
  ('rook reaches last rank', {'board': {'a1': 'R'}, 'uci': 'a1a8'}, 'ok'),
  ('king promotion', {'board': {'e7': 'P'}, 'uci': 'e7e8k'}, 'bad promotion'),
  ('pawn promotion letter', {'board': {'c7': 'P'}, 'uci': 'c7c8p'}, 'bad promotion'),
  ('suffix on quiet move', {'board': {'g1': 'N'}, 'uci': 'g1f3q'}, 'unexpected promotion'),
  ('null move', {'board': {'e2': 'P'}, 'uci': 'e2e2'}, 'syntax'),
  ('too long', {'board': {'e7': 'P'}, 'uci': 'e7e8qq'}, 'syntax'),
  ('too short', {'board': {'e2': 'P'}, 'uci': 'e2e'}, 'syntax')],
 [('pawn promotion letter', {'board': {'c7': 'P'}, 'uci': 'c7c8p'}, 'bad promotion'),
  ('suffix on quiet move', {'board': {'g1': 'N'}, 'uci': 'g1f3q'}, 'unexpected promotion'),
  ('null move', {'board': {'e2': 'P'}, 'uci': 'e2e2'}, 'syntax'),
  ('vertical rook move', {'board': {'h1': 'R'}, 'uci': 'h1h5'}, 'ok'),
  ('empty origin', {'board': {'e2': 'P'}, 'uci': 'd2d4'}, 'no piece'),
  ('too long', {'board': {'e7': 'P'}, 'uci': 'e7e8qq'}, 'syntax'),
  ('too short', {'board': {'e2': 'P'}, 'uci': 'e2e'}, 'syntax'),
  ('castling encoding', {'board': {'e1': 'K', 'h1': 'R'}, 'uci': 'e1g1'}, 'ok')],
 [('simple move', {'board': {'e2': 'P'}, 'uci': 'e2e4'}, 'ok'),
  ('rank nine', {'board': {'e2': 'P'}, 'uci': 'e2e9'}, 'syntax'),
  ('rank zero', {'board': {'e2': 'P'}, 'uci': 'e2e0'}, 'syntax'),
  ('vertical rook move', {'board': {'h1': 'R'}, 'uci': 'h1h5'}, 'ok'),
  ('empty origin', {'board': {'e2': 'P'}, 'uci': 'd2d4'}, 'no piece'),
  ('too long', {'board': {'e7': 'P'}, 'uci': 'e7e8qq'}, 'syntax'),
  ('too short', {'board': {'e2': 'P'}, 'uci': 'e2e'}, 'syntax'),
  ('castling encoding', {'board': {'e1': 'K', 'h1': 'R'}, 'uci': 'e1g1'}, 'ok')]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
simple moveokokPassed
rank ninesyntaxsyntaxPassed
rank zerosyntaxsyntaxPassed
white promotionokokPassed
white needs promotionpromotion requiredpromotion requiredPassed
black needs promotionpromotion requiredpromotion requiredPassed
too longbad promotionsyntaxFailed
too shortsyntaxsyntaxPassed

SHA-256 / 3b7142266b6ac59ea4861081eaa455d63c40cd64786348ef3bb45e7a03ee62d8

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    u=x['uci']; b=x['board']
    if len(u)>5: return 'syntax'
    fr,to,promo=u[:2],u[2:4],u[4:]
    for s in (fr,to):
        if s[0] not in 'abcdefgh' or s[1] not in '12345678': return 'syntax'
    if fr==to: return 'syntax'
    p=b.get(fr)
    if p is None: return 'no piece'
    last=(p=='P' and to[1]=='8') or (p=='p' and to[1]=='1')
    if last and not promo: return 'promotion required'
    if promo and not last: return 'unexpected promotion'
    if promo and promo not in 'qrbn': return 'bad promotion'
    return 'ok'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('simple move', {'board': {'e2': 'P'}, 'uci': 'e2e4'}, 'ok'),
  ('rank nine', {'board': {'e2': 'P'}, 'uci': 'e2e9'}, 'syntax'),
  ('rank zero', {'board': {'e2': 'P'}, 'uci': 'e2e0'}, 'syntax'),
  ('white promotion', {'board': {'e7': 'P'}, 'uci': 'e7e8q'}, 'ok'),
  ('white needs promotion', {'board': {'e7': 'P'}, 'uci': 'e7e8'}, 'promotion required'),
  ('black needs promotion', {'board': {'b2': 'p'}, 'uci': 'b2b1'}, 'promotion required'),
  ('too long', {'board': {'e7': 'P'}, 'uci': 'e7e8qq'}, 'syntax'),
  ('too short', {'board': {'e2': 'P'}, 'uci': 'e2e'}, 'syntax')],
 [('white promotion', {'board': {'e7': 'P'}, 'uci': 'e7e8q'}, 'ok'),
  ('white needs promotion', {'board': {'e7': 'P'}, 'uci': 'e7e8'}, 'promotion required'),
  ('black needs promotion', {'board': {'b2': 'p'}, 'uci': 'b2b1'}, 'promotion required'),
  ('black promotes knight', {'board': {'b2': 'p'}, 'uci': 'b2a1n'}, 'ok'),
  ('rook reaches last rank', {'board': {'a1': 'R'}, 'uci': 'a1a8'}, 'ok'),
  ('king promotion', {'board': {'e7': 'P'}, 'uci': 'e7e8k'}, 'bad promotion'),
  ('too long', {'board': {'e7': 'P'}, 'uci': 'e7e8qq'}, 'syntax'),
  ('too short', {'board': {'e2': 'P'}, 'uci': 'e2e'}, 'syntax')],
 [('black promotes knight', {'board': {'b2': 'p'}, 'uci': 'b2a1n'}, 'ok'),
  ('rook reaches last rank', {'board': {'a1': 'R'}, 'uci': 'a1a8'}, 'ok'),
  ('king promotion', {'board': {'e7': 'P'}, 'uci': 'e7e8k'}, 'bad promotion'),
  ('pawn promotion letter', {'board': {'c7': 'P'}, 'uci': 'c7c8p'}, 'bad promotion'),
  ('suffix on quiet move', {'board': {'g1': 'N'}, 'uci': 'g1f3q'}, 'unexpected promotion'),
  ('null move', {'board': {'e2': 'P'}, 'uci': 'e2e2'}, 'syntax'),
  ('too long', {'board': {'e7': 'P'}, 'uci': 'e7e8qq'}, 'syntax'),
  ('too short', {'board': {'e2': 'P'}, 'uci': 'e2e'}, 'syntax')],
 [('pawn promotion letter', {'board': {'c7': 'P'}, 'uci': 'c7c8p'}, 'bad promotion'),
  ('suffix on quiet move', {'board': {'g1': 'N'}, 'uci': 'g1f3q'}, 'unexpected promotion'),
  ('null move', {'board': {'e2': 'P'}, 'uci': 'e2e2'}, 'syntax'),
  ('vertical rook move', {'board': {'h1': 'R'}, 'uci': 'h1h5'}, 'ok'),
  ('empty origin', {'board': {'e2': 'P'}, 'uci': 'd2d4'}, 'no piece'),
  ('too long', {'board': {'e7': 'P'}, 'uci': 'e7e8qq'}, 'syntax'),
  ('too short', {'board': {'e2': 'P'}, 'uci': 'e2e'}, 'syntax'),
  ('castling encoding', {'board': {'e1': 'K', 'h1': 'R'}, 'uci': 'e1g1'}, 'ok')],
 [('simple move', {'board': {'e2': 'P'}, 'uci': 'e2e4'}, 'ok'),
  ('rank nine', {'board': {'e2': 'P'}, 'uci': 'e2e9'}, 'syntax'),
  ('rank zero', {'board': {'e2': 'P'}, 'uci': 'e2e0'}, 'syntax'),
  ('vertical rook move', {'board': {'h1': 'R'}, 'uci': 'h1h5'}, 'ok'),
  ('empty origin', {'board': {'e2': 'P'}, 'uci': 'd2d4'}, 'no piece'),
  ('too long', {'board': {'e7': 'P'}, 'uci': 'e7e8qq'}, 'syntax'),
  ('too short', {'board': {'e2': 'P'}, 'uci': 'e2e'}, 'syntax'),
  ('castling encoding', {'board': {'e1': 'K', 'h1': 'R'}, 'uci': 'e1g1'}, 'ok')]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
simple moveokokPassed
rank ninesyntaxsyntaxPassed
rank zerosyntaxsyntaxPassed
white promotionokokPassed
white needs promotionpromotion requiredpromotion requiredPassed
black needs promotionpromotion requiredpromotion requiredPassed
too longsyntaxsyntaxPassed
too shorterror:IndexErrorsyntaxFailed

SHA-256 / c13a4cac992d0e4140e1e73bf63afe0b41f47793a7b02619da36fcccca2a6869

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    u=x['uci']; b=x['board']
    if len(u) not in (4,5): return 'syntax'
    fr,to,promo=u[:2],u[2:4],u[4:]
    for s in (fr,to):
        if s[0] not in 'abcdefgh' or s[1] not in '12345678': return 'syntax'
    if fr==to: return 'syntax'
    p=b.get(fr)
    if p is None: return 'no piece'
    last=(p=='P' and to[1]=='8') or (p=='p' and to[1]=='1')
    if last and not promo: return 'promotion required'
    if promo and not last: return 'unexpected promotion'
    if promo and promo not in 'qrbn': return 'bad promotion'
    return 'ok'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('simple move', {'board': {'e2': 'P'}, 'uci': 'e2e4'}, 'ok'),
  ('rank nine', {'board': {'e2': 'P'}, 'uci': 'e2e9'}, 'syntax'),
  ('rank zero', {'board': {'e2': 'P'}, 'uci': 'e2e0'}, 'syntax'),
  ('white promotion', {'board': {'e7': 'P'}, 'uci': 'e7e8q'}, 'ok'),
  ('white needs promotion', {'board': {'e7': 'P'}, 'uci': 'e7e8'}, 'promotion required'),
  ('black needs promotion', {'board': {'b2': 'p'}, 'uci': 'b2b1'}, 'promotion required'),
  ('too long', {'board': {'e7': 'P'}, 'uci': 'e7e8qq'}, 'syntax'),
  ('too short', {'board': {'e2': 'P'}, 'uci': 'e2e'}, 'syntax')],
 [('white promotion', {'board': {'e7': 'P'}, 'uci': 'e7e8q'}, 'ok'),
  ('white needs promotion', {'board': {'e7': 'P'}, 'uci': 'e7e8'}, 'promotion required'),
  ('black needs promotion', {'board': {'b2': 'p'}, 'uci': 'b2b1'}, 'promotion required'),
  ('black promotes knight', {'board': {'b2': 'p'}, 'uci': 'b2a1n'}, 'ok'),
  ('rook reaches last rank', {'board': {'a1': 'R'}, 'uci': 'a1a8'}, 'ok'),
  ('king promotion', {'board': {'e7': 'P'}, 'uci': 'e7e8k'}, 'bad promotion'),
  ('too long', {'board': {'e7': 'P'}, 'uci': 'e7e8qq'}, 'syntax'),
  ('too short', {'board': {'e2': 'P'}, 'uci': 'e2e'}, 'syntax')],
 [('black promotes knight', {'board': {'b2': 'p'}, 'uci': 'b2a1n'}, 'ok'),
  ('rook reaches last rank', {'board': {'a1': 'R'}, 'uci': 'a1a8'}, 'ok'),
  ('king promotion', {'board': {'e7': 'P'}, 'uci': 'e7e8k'}, 'bad promotion'),
  ('pawn promotion letter', {'board': {'c7': 'P'}, 'uci': 'c7c8p'}, 'bad promotion'),
  ('suffix on quiet move', {'board': {'g1': 'N'}, 'uci': 'g1f3q'}, 'unexpected promotion'),
  ('null move', {'board': {'e2': 'P'}, 'uci': 'e2e2'}, 'syntax'),
  ('too long', {'board': {'e7': 'P'}, 'uci': 'e7e8qq'}, 'syntax'),
  ('too short', {'board': {'e2': 'P'}, 'uci': 'e2e'}, 'syntax')],
 [('pawn promotion letter', {'board': {'c7': 'P'}, 'uci': 'c7c8p'}, 'bad promotion'),
  ('suffix on quiet move', {'board': {'g1': 'N'}, 'uci': 'g1f3q'}, 'unexpected promotion'),
  ('null move', {'board': {'e2': 'P'}, 'uci': 'e2e2'}, 'syntax'),
  ('vertical rook move', {'board': {'h1': 'R'}, 'uci': 'h1h5'}, 'ok'),
  ('empty origin', {'board': {'e2': 'P'}, 'uci': 'd2d4'}, 'no piece'),
  ('too long', {'board': {'e7': 'P'}, 'uci': 'e7e8qq'}, 'syntax'),
  ('too short', {'board': {'e2': 'P'}, 'uci': 'e2e'}, 'syntax'),
  ('castling encoding', {'board': {'e1': 'K', 'h1': 'R'}, 'uci': 'e1g1'}, 'ok')],
 [('simple move', {'board': {'e2': 'P'}, 'uci': 'e2e4'}, 'ok'),
  ('rank nine', {'board': {'e2': 'P'}, 'uci': 'e2e9'}, 'syntax'),
  ('rank zero', {'board': {'e2': 'P'}, 'uci': 'e2e0'}, 'syntax'),
  ('vertical rook move', {'board': {'h1': 'R'}, 'uci': 'h1h5'}, 'ok'),
  ('empty origin', {'board': {'e2': 'P'}, 'uci': 'd2d4'}, 'no piece'),
  ('too long', {'board': {'e7': 'P'}, 'uci': 'e7e8qq'}, 'syntax'),
  ('too short', {'board': {'e2': 'P'}, 'uci': 'e2e'}, 'syntax'),
  ('castling encoding', {'board': {'e1': 'K', 'h1': 'R'}, 'uci': 'e1g1'}, 'ok')]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
simple moveokokPassed
rank ninesyntaxsyntaxPassed
rank zerosyntaxsyntaxPassed
white promotionokokPassed
white needs promotionpromotion requiredpromotion requiredPassed
black needs promotionpromotion requiredpromotion requiredPassed
too longsyntaxsyntaxPassed
too shortsyntaxsyntaxPassed

SHA-256 / 253a52a86a863328b29d981d11cf9699cb12916b65e97fd2947b0844e1d53244

Verification & scope

A deterministic toy model with an explicitly stated contract; boards are {square: piece} with white upper-case and black lower-case pieces; no claim of full FIDE Laws conformance. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:50:13.983201+00:00.

Case digest / 38f39248bc95748eec57076884cb44b38faafe28f0b97921ef3806503249b408