FAILURE MAP
← Case archive

FA-76471 / Email MIME structure / Open access

Resolve cid: references inside multipart/related: scheme case · case 01

References written as "CID:" are not recognised as content-id URLs.

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

ROOT CAUSE

The scheme case decision evaluates `ref.startswith('cid:')` where the contract requires `ref[:4].lower() == 'cid:'`.

VERIFIED REPAIR

Use `ref[:4].lower() == 'cid:'` for the scheme case decision and keep every other rule of the model unchanged.

Unsuccessful approach: Enumerating two spellings still misses mixed-case schemes. The attempted `ref[:4] in ('cid:', 'CID:')` still disagrees with a fixture.

Case contract

related has params (optional start, with angle brackets) and parts with optional cid values such as " <img@x> ". Content ids are compared after trimming spaces and angle brackets. The root is the part whose id equals the start id, else the first part. Each reference is a URL; the "cid:" scheme is case-insensitive and the rest is percent-decoded. A reference resolves to the first non-root part with an equal id, else None. Result {root, resolved [[ref, index]...], unused: non-root indexes nobody referenced}.

Why this case matters

Inline images and style sheets in HTML mail are located through Content-ID references.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from urllib.parse import unquote
N = 1
observations = []
def solve(related, html_refs):
    def norm(c):
        return (c or '').strip().strip('<>').strip()
    ids = [norm(p.get('cid')) for p in related['parts']]
    start = norm(related.get('params', {}).get('start'))
    root = ids.index(start) if start and start in ids else 0
    resolved = []
    used = set()
    for ref in html_refs:
        target = unquote(ref[4:]) if ref.startswith('cid:') else None
        hit = None
        for i, c in enumerate(ids):
            if i != root and target and c == target:
                hit = i
                break
        if hit is not None:
            used.add(hit)
        resolved.append([ref, hit])
    unused = [i for i in range(len(ids)) if i != root and i not in used]
    return {'root': root, 'resolved': resolved, 'unused': unused}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('padded content id', ({'parts': [{'cid': '<root@x>'}, {'cid': ' <pic1@x> '}]}, ['cid:pic1@x']), {'resolved': [['cid:pic1@x', 1]], 'root': 0, 'unused': []}), ('scheme casing', ({'parts': [{'cid': '<root@x>'}, {'cid': '<pic@x>'}]}, ['CID:pic@x', 'Cid:pic@x', 'http://pic@x']), {'resolved': [['CID:pic@x', 1], ['Cid:pic@x', 1], ['http://pic@x', None]], 'root': 0, 'unused': []}), ('percent-encoded reference', ({'parts': [{}, {'cid': '<a+b1@x>'}]}, ['cid:a%2Bb1%40x']), {'resolved': [['cid:a%2Bb1%40x', 1]], 'root': 0, 'unused': []}), ('root referenced by itself', ({'params': {'start': '<root@x>'}, 'parts': [{'cid': '<pic@x>'}, {'cid': '<root@x>'}]}, ['cid:root@x', 'cid:pic@x']), {'resolved': [['cid:root@x', None], ['cid:pic@x', 0]], 'root': 1, 'unused': []}), ('no start and an id-less part', ({'params': {}, 'parts': [{'cid': '<doc@x>'}, {}, {'cid': '<p1@x>'}]}, ['cid:p1@x']), {'resolved': [['cid:p1@x', 2]], 'root': 0, 'unused': [1]}), ('unused parts with late root', ({'params': {'start': '<r@x>'}, 'parts': [{'cid': '<a@x>'}, {'cid': '<b@x>'}, {'cid': '<r@x>'}]}, ['cid:a@x']), {'resolved': [['cid:a@x', 0]], 'root': 2, 'unused': [1]})], 2: [('padded content id', ({'parts': [{'cid': '<root@x>'}, {'cid': ' <pic2@x> '}]}, ['cid:pic2@x']), {'resolved': [['cid:pic2@x', 1]], 'root': 0, 'unused': []}), ('scheme casing', ({'parts': [{'cid': '<root@x>'}, {'cid': '<pic@x>'}]}, ['CID:pic@x', 'Cid:pic@x', 'http://pic@x']), {'resolved': [['CID:pic@x', 1], ['Cid:pic@x', 1], ['http://pic@x', None]], 'root': 0, 'unused': []}), ('percent-encoded reference', ({'parts': [{}, {'cid': '<a+b2@x>'}]}, ['cid:a%2Bb2%40x']), {'resolved': [['cid:a%2Bb2%40x', 1]], 'root': 0, 'unused': []}), ('root referenced by itself', ({'params': {'start': '<root@x>'}, 'parts': [{'cid': '<pic@x>'}, {'cid': '<root@x>'}]}, ['cid:root@x', 'cid:pic@x']), {'resolved': [['cid:root@x', None], ['cid:pic@x', 0]], 'root': 1, 'unused': []}), ('no start and an id-less part', ({'params': {}, 'parts': [{'cid': '<doc@x>'}, {}, {'cid': '<p2@x>'}]}, ['cid:p2@x']), {'resolved': [['cid:p2@x', 2]], 'root': 0, 'unused': [1]}), ('unused parts with late root', ({'params': {'start': '<r@x>'}, 'parts': [{'cid': '<a@x>'}, {'cid': '<b@x>'}, {'cid': '<r@x>'}]}, ['cid:a@x']), {'resolved': [['cid:a@x', 0]], 'root': 2, 'unused': [1]})], 3: [('padded content id', ({'parts': [{'cid': '<root@x>'}, {'cid': ' <pic3@x> '}]}, ['cid:pic3@x']), {'resolved': [['cid:pic3@x', 1]], 'root': 0, 'unused': []}), ('scheme casing', ({'parts': [{'cid': '<root@x>'}, {'cid': '<pic@x>'}]}, ['CID:pic@x', 'Cid:pic@x', 'http://pic@x']), {'resolved': [['CID:pic@x', 1], ['Cid:pic@x', 1], ['http://pic@x', None]], 'root': 0, 'unused': []}), ('percent-encoded reference', ({'parts': [{}, {'cid': '<a+b3@x>'}]}, ['cid:a%2Bb3%40x']), {'resolved': [['cid:a%2Bb3%40x', 1]], 'root': 0, 'unused': []}), ('root referenced by itself', ({'params': {'start': '<root@x>'}, 'parts': [{'cid': '<pic@x>'}, {'cid': '<root@x>'}]}, ['cid:root@x', 'cid:pic@x']), {'resolved': [['cid:root@x', None], ['cid:pic@x', 0]], 'root': 1, 'unused': []}), ('no start and an id-less part', ({'params': {}, 'parts': [{'cid': '<doc@x>'}, {}, {'cid': '<p3@x>'}]}, ['cid:p3@x']), {'resolved': [['cid:p3@x', 2]], 'root': 0, 'unused': [1]}), ('unused parts with late root', ({'params': {'start': '<r@x>'}, 'parts': [{'cid': '<a@x>'}, {'cid': '<b@x>'}, {'cid': '<r@x>'}]}, ['cid:a@x']), {'resolved': [['cid:a@x', 0]], 'root': 2, 'unused': [1]})], 4: [('padded content id', ({'parts': [{'cid': '<root@x>'}, {'cid': ' <pic4@x> '}]}, ['cid:pic4@x']), {'resolved': [['cid:pic4@x', 1]], 'root': 0, 'unused': []}), ('scheme casing', ({'parts': [{'cid': '<root@x>'}, {'cid': '<pic@x>'}]}, ['CID:pic@x', 'Cid:pic@x', 'http://pic@x']), {'resolved': [['CID:pic@x', 1], ['Cid:pic@x', 1], ['http://pic@x', None]], 'root': 0, 'unused': []}), ('percent-encoded reference', ({'parts': [{}, {'cid': '<a+b4@x>'}]}, ['cid:a%2Bb4%40x']), {'resolved': [['cid:a%2Bb4%40x', 1]], 'root': 0, 'unused': []}), ('root referenced by itself', ({'params': {'start': '<root@x>'}, 'parts': [{'cid': '<pic@x>'}, {'cid': '<root@x>'}]}, ['cid:root@x', 'cid:pic@x']), {'resolved': [['cid:root@x', None], ['cid:pic@x', 0]], 'root': 1, 'unused': []}), ('no start and an id-less part', ({'params': {}, 'parts': [{'cid': '<doc@x>'}, {}, {'cid': '<p4@x>'}]}, ['cid:p4@x']), {'resolved': [['cid:p4@x', 2]], 'root': 0, 'unused': [1]}), ('unused parts with late root', ({'params': {'start': '<r@x>'}, 'parts': [{'cid': '<a@x>'}, {'cid': '<b@x>'}, {'cid': '<r@x>'}]}, ['cid:a@x']), {'resolved': [['cid:a@x', 0]], 'root': 2, 'unused': [1]})], 5: [('padded content id', ({'parts': [{'cid': '<root@x>'}, {'cid': ' <pic5@x> '}]}, ['cid:pic5@x']), {'resolved': [['cid:pic5@x', 1]], 'root': 0, 'unused': []}), ('scheme casing', ({'parts': [{'cid': '<root@x>'}, {'cid': '<pic@x>'}]}, ['CID:pic@x', 'Cid:pic@x', 'http://pic@x']), {'resolved': [['CID:pic@x', 1], ['Cid:pic@x', 1], ['http://pic@x', None]], 'root': 0, 'unused': []}), ('percent-encoded reference', ({'parts': [{}, {'cid': '<a+b5@x>'}]}, ['cid:a%2Bb5%40x']), {'resolved': [['cid:a%2Bb5%40x', 1]], 'root': 0, 'unused': []}), ('root referenced by itself', ({'params': {'start': '<root@x>'}, 'parts': [{'cid': '<pic@x>'}, {'cid': '<root@x>'}]}, ['cid:root@x', 'cid:pic@x']), {'resolved': [['cid:root@x', None], ['cid:pic@x', 0]], 'root': 1, 'unused': []}), ('no start and an id-less part', ({'params': {}, 'parts': [{'cid': '<doc@x>'}, {}, {'cid': '<p5@x>'}]}, ['cid:p5@x']), {'resolved': [['cid:p5@x', 2]], 'root': 0, 'unused': [1]}), ('unused parts with late root', ({'params': {'start': '<r@x>'}, 'parts': [{'cid': '<a@x>'}, {'cid': '<b@x>'}, {'cid': '<r@x>'}]}, ['cid:a@x']), {'resolved': [['cid:a@x', 0]], 'root': 2, 'unused': [1]})]}
for _label, _args, _expected in _CASES[N]:
    check(_label, solve(*_args), _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
padded content id{'resolved': [['cid:pic1@x', 1]], 'root': 0, 'unused': []}{'resolved': [['cid:pic1@x', 1]], 'root': 0, 'unused': []}Passed
scheme casing{'resolved': [['CID:pic@x', None], ['Cid:pic@x', None], ['http://pic@x', None]], 'root': 0, 'unused': [1]}{'resolved': [['CID:pic@x', 1], ['Cid:pic@x', 1], ['http://pic@x', None]], 'root': 0, 'unused': []}Failed
percent-encoded reference{'resolved': [['cid:a%2Bb1%40x', 1]], 'root': 0, 'unused': []}{'resolved': [['cid:a%2Bb1%40x', 1]], 'root': 0, 'unused': []}Passed
root referenced by itself{'resolved': [['cid:root@x', None], ['cid:pic@x', 0]], 'root': 1, 'unused': []}{'resolved': [['cid:root@x', None], ['cid:pic@x', 0]], 'root': 1, 'unused': []}Passed
no start and an id-less part{'resolved': [['cid:p1@x', 2]], 'root': 0, 'unused': [1]}{'resolved': [['cid:p1@x', 2]], 'root': 0, 'unused': [1]}Passed
unused parts with late root{'resolved': [['cid:a@x', 0]], 'root': 2, 'unused': [1]}{'resolved': [['cid:a@x', 0]], 'root': 2, 'unused': [1]}Passed

SHA-256 / aa5761e4bf961fb76278d4bb049ff3944439ba10f7659901d04ab06fe1cdd64d

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from urllib.parse import unquote
N = 1
observations = []
def solve(related, html_refs):
    def norm(c):
        return (c or '').strip().strip('<>').strip()
    ids = [norm(p.get('cid')) for p in related['parts']]
    start = norm(related.get('params', {}).get('start'))
    root = ids.index(start) if start and start in ids else 0
    resolved = []
    used = set()
    for ref in html_refs:
        target = unquote(ref[4:]) if ref[:4] in ('cid:', 'CID:') else None
        hit = None
        for i, c in enumerate(ids):
            if i != root and target and c == target:
                hit = i
                break
        if hit is not None:
            used.add(hit)
        resolved.append([ref, hit])
    unused = [i for i in range(len(ids)) if i != root and i not in used]
    return {'root': root, 'resolved': resolved, 'unused': unused}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('padded content id', ({'parts': [{'cid': '<root@x>'}, {'cid': ' <pic1@x> '}]}, ['cid:pic1@x']), {'resolved': [['cid:pic1@x', 1]], 'root': 0, 'unused': []}), ('scheme casing', ({'parts': [{'cid': '<root@x>'}, {'cid': '<pic@x>'}]}, ['CID:pic@x', 'Cid:pic@x', 'http://pic@x']), {'resolved': [['CID:pic@x', 1], ['Cid:pic@x', 1], ['http://pic@x', None]], 'root': 0, 'unused': []}), ('percent-encoded reference', ({'parts': [{}, {'cid': '<a+b1@x>'}]}, ['cid:a%2Bb1%40x']), {'resolved': [['cid:a%2Bb1%40x', 1]], 'root': 0, 'unused': []}), ('root referenced by itself', ({'params': {'start': '<root@x>'}, 'parts': [{'cid': '<pic@x>'}, {'cid': '<root@x>'}]}, ['cid:root@x', 'cid:pic@x']), {'resolved': [['cid:root@x', None], ['cid:pic@x', 0]], 'root': 1, 'unused': []}), ('no start and an id-less part', ({'params': {}, 'parts': [{'cid': '<doc@x>'}, {}, {'cid': '<p1@x>'}]}, ['cid:p1@x']), {'resolved': [['cid:p1@x', 2]], 'root': 0, 'unused': [1]}), ('unused parts with late root', ({'params': {'start': '<r@x>'}, 'parts': [{'cid': '<a@x>'}, {'cid': '<b@x>'}, {'cid': '<r@x>'}]}, ['cid:a@x']), {'resolved': [['cid:a@x', 0]], 'root': 2, 'unused': [1]})], 2: [('padded content id', ({'parts': [{'cid': '<root@x>'}, {'cid': ' <pic2@x> '}]}, ['cid:pic2@x']), {'resolved': [['cid:pic2@x', 1]], 'root': 0, 'unused': []}), ('scheme casing', ({'parts': [{'cid': '<root@x>'}, {'cid': '<pic@x>'}]}, ['CID:pic@x', 'Cid:pic@x', 'http://pic@x']), {'resolved': [['CID:pic@x', 1], ['Cid:pic@x', 1], ['http://pic@x', None]], 'root': 0, 'unused': []}), ('percent-encoded reference', ({'parts': [{}, {'cid': '<a+b2@x>'}]}, ['cid:a%2Bb2%40x']), {'resolved': [['cid:a%2Bb2%40x', 1]], 'root': 0, 'unused': []}), ('root referenced by itself', ({'params': {'start': '<root@x>'}, 'parts': [{'cid': '<pic@x>'}, {'cid': '<root@x>'}]}, ['cid:root@x', 'cid:pic@x']), {'resolved': [['cid:root@x', None], ['cid:pic@x', 0]], 'root': 1, 'unused': []}), ('no start and an id-less part', ({'params': {}, 'parts': [{'cid': '<doc@x>'}, {}, {'cid': '<p2@x>'}]}, ['cid:p2@x']), {'resolved': [['cid:p2@x', 2]], 'root': 0, 'unused': [1]}), ('unused parts with late root', ({'params': {'start': '<r@x>'}, 'parts': [{'cid': '<a@x>'}, {'cid': '<b@x>'}, {'cid': '<r@x>'}]}, ['cid:a@x']), {'resolved': [['cid:a@x', 0]], 'root': 2, 'unused': [1]})], 3: [('padded content id', ({'parts': [{'cid': '<root@x>'}, {'cid': ' <pic3@x> '}]}, ['cid:pic3@x']), {'resolved': [['cid:pic3@x', 1]], 'root': 0, 'unused': []}), ('scheme casing', ({'parts': [{'cid': '<root@x>'}, {'cid': '<pic@x>'}]}, ['CID:pic@x', 'Cid:pic@x', 'http://pic@x']), {'resolved': [['CID:pic@x', 1], ['Cid:pic@x', 1], ['http://pic@x', None]], 'root': 0, 'unused': []}), ('percent-encoded reference', ({'parts': [{}, {'cid': '<a+b3@x>'}]}, ['cid:a%2Bb3%40x']), {'resolved': [['cid:a%2Bb3%40x', 1]], 'root': 0, 'unused': []}), ('root referenced by itself', ({'params': {'start': '<root@x>'}, 'parts': [{'cid': '<pic@x>'}, {'cid': '<root@x>'}]}, ['cid:root@x', 'cid:pic@x']), {'resolved': [['cid:root@x', None], ['cid:pic@x', 0]], 'root': 1, 'unused': []}), ('no start and an id-less part', ({'params': {}, 'parts': [{'cid': '<doc@x>'}, {}, {'cid': '<p3@x>'}]}, ['cid:p3@x']), {'resolved': [['cid:p3@x', 2]], 'root': 0, 'unused': [1]}), ('unused parts with late root', ({'params': {'start': '<r@x>'}, 'parts': [{'cid': '<a@x>'}, {'cid': '<b@x>'}, {'cid': '<r@x>'}]}, ['cid:a@x']), {'resolved': [['cid:a@x', 0]], 'root': 2, 'unused': [1]})], 4: [('padded content id', ({'parts': [{'cid': '<root@x>'}, {'cid': ' <pic4@x> '}]}, ['cid:pic4@x']), {'resolved': [['cid:pic4@x', 1]], 'root': 0, 'unused': []}), ('scheme casing', ({'parts': [{'cid': '<root@x>'}, {'cid': '<pic@x>'}]}, ['CID:pic@x', 'Cid:pic@x', 'http://pic@x']), {'resolved': [['CID:pic@x', 1], ['Cid:pic@x', 1], ['http://pic@x', None]], 'root': 0, 'unused': []}), ('percent-encoded reference', ({'parts': [{}, {'cid': '<a+b4@x>'}]}, ['cid:a%2Bb4%40x']), {'resolved': [['cid:a%2Bb4%40x', 1]], 'root': 0, 'unused': []}), ('root referenced by itself', ({'params': {'start': '<root@x>'}, 'parts': [{'cid': '<pic@x>'}, {'cid': '<root@x>'}]}, ['cid:root@x', 'cid:pic@x']), {'resolved': [['cid:root@x', None], ['cid:pic@x', 0]], 'root': 1, 'unused': []}), ('no start and an id-less part', ({'params': {}, 'parts': [{'cid': '<doc@x>'}, {}, {'cid': '<p4@x>'}]}, ['cid:p4@x']), {'resolved': [['cid:p4@x', 2]], 'root': 0, 'unused': [1]}), ('unused parts with late root', ({'params': {'start': '<r@x>'}, 'parts': [{'cid': '<a@x>'}, {'cid': '<b@x>'}, {'cid': '<r@x>'}]}, ['cid:a@x']), {'resolved': [['cid:a@x', 0]], 'root': 2, 'unused': [1]})], 5: [('padded content id', ({'parts': [{'cid': '<root@x>'}, {'cid': ' <pic5@x> '}]}, ['cid:pic5@x']), {'resolved': [['cid:pic5@x', 1]], 'root': 0, 'unused': []}), ('scheme casing', ({'parts': [{'cid': '<root@x>'}, {'cid': '<pic@x>'}]}, ['CID:pic@x', 'Cid:pic@x', 'http://pic@x']), {'resolved': [['CID:pic@x', 1], ['Cid:pic@x', 1], ['http://pic@x', None]], 'root': 0, 'unused': []}), ('percent-encoded reference', ({'parts': [{}, {'cid': '<a+b5@x>'}]}, ['cid:a%2Bb5%40x']), {'resolved': [['cid:a%2Bb5%40x', 1]], 'root': 0, 'unused': []}), ('root referenced by itself', ({'params': {'start': '<root@x>'}, 'parts': [{'cid': '<pic@x>'}, {'cid': '<root@x>'}]}, ['cid:root@x', 'cid:pic@x']), {'resolved': [['cid:root@x', None], ['cid:pic@x', 0]], 'root': 1, 'unused': []}), ('no start and an id-less part', ({'params': {}, 'parts': [{'cid': '<doc@x>'}, {}, {'cid': '<p5@x>'}]}, ['cid:p5@x']), {'resolved': [['cid:p5@x', 2]], 'root': 0, 'unused': [1]}), ('unused parts with late root', ({'params': {'start': '<r@x>'}, 'parts': [{'cid': '<a@x>'}, {'cid': '<b@x>'}, {'cid': '<r@x>'}]}, ['cid:a@x']), {'resolved': [['cid:a@x', 0]], 'root': 2, 'unused': [1]})]}
for _label, _args, _expected in _CASES[N]:
    check(_label, solve(*_args), _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
padded content id{'resolved': [['cid:pic1@x', 1]], 'root': 0, 'unused': []}{'resolved': [['cid:pic1@x', 1]], 'root': 0, 'unused': []}Passed
scheme casing{'resolved': [['CID:pic@x', 1], ['Cid:pic@x', None], ['http://pic@x', None]], 'root': 0, 'unused': []}{'resolved': [['CID:pic@x', 1], ['Cid:pic@x', 1], ['http://pic@x', None]], 'root': 0, 'unused': []}Failed
percent-encoded reference{'resolved': [['cid:a%2Bb1%40x', 1]], 'root': 0, 'unused': []}{'resolved': [['cid:a%2Bb1%40x', 1]], 'root': 0, 'unused': []}Passed
root referenced by itself{'resolved': [['cid:root@x', None], ['cid:pic@x', 0]], 'root': 1, 'unused': []}{'resolved': [['cid:root@x', None], ['cid:pic@x', 0]], 'root': 1, 'unused': []}Passed
no start and an id-less part{'resolved': [['cid:p1@x', 2]], 'root': 0, 'unused': [1]}{'resolved': [['cid:p1@x', 2]], 'root': 0, 'unused': [1]}Passed
unused parts with late root{'resolved': [['cid:a@x', 0]], 'root': 2, 'unused': [1]}{'resolved': [['cid:a@x', 0]], 'root': 2, 'unused': [1]}Passed

SHA-256 / 63dbb99dd4af6d485223426c15e6718d48e933948b2f84a8f685e733c0e97934

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
from urllib.parse import unquote
N = 1
observations = []
def solve(related, html_refs):
    def norm(c):
        return (c or '').strip().strip('<>').strip()
    ids = [norm(p.get('cid')) for p in related['parts']]
    start = norm(related.get('params', {}).get('start'))
    root = ids.index(start) if start and start in ids else 0
    resolved = []
    used = set()
    for ref in html_refs:
        target = unquote(ref[4:]) if ref[:4].lower() == 'cid:' else None
        hit = None
        for i, c in enumerate(ids):
            if i != root and target and c == target:
                hit = i
                break
        if hit is not None:
            used.add(hit)
        resolved.append([ref, hit])
    unused = [i for i in range(len(ids)) if i != root and i not in used]
    return {'root': root, 'resolved': resolved, 'unused': unused}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('padded content id', ({'parts': [{'cid': '<root@x>'}, {'cid': ' <pic1@x> '}]}, ['cid:pic1@x']), {'resolved': [['cid:pic1@x', 1]], 'root': 0, 'unused': []}), ('scheme casing', ({'parts': [{'cid': '<root@x>'}, {'cid': '<pic@x>'}]}, ['CID:pic@x', 'Cid:pic@x', 'http://pic@x']), {'resolved': [['CID:pic@x', 1], ['Cid:pic@x', 1], ['http://pic@x', None]], 'root': 0, 'unused': []}), ('percent-encoded reference', ({'parts': [{}, {'cid': '<a+b1@x>'}]}, ['cid:a%2Bb1%40x']), {'resolved': [['cid:a%2Bb1%40x', 1]], 'root': 0, 'unused': []}), ('root referenced by itself', ({'params': {'start': '<root@x>'}, 'parts': [{'cid': '<pic@x>'}, {'cid': '<root@x>'}]}, ['cid:root@x', 'cid:pic@x']), {'resolved': [['cid:root@x', None], ['cid:pic@x', 0]], 'root': 1, 'unused': []}), ('no start and an id-less part', ({'params': {}, 'parts': [{'cid': '<doc@x>'}, {}, {'cid': '<p1@x>'}]}, ['cid:p1@x']), {'resolved': [['cid:p1@x', 2]], 'root': 0, 'unused': [1]}), ('unused parts with late root', ({'params': {'start': '<r@x>'}, 'parts': [{'cid': '<a@x>'}, {'cid': '<b@x>'}, {'cid': '<r@x>'}]}, ['cid:a@x']), {'resolved': [['cid:a@x', 0]], 'root': 2, 'unused': [1]})], 2: [('padded content id', ({'parts': [{'cid': '<root@x>'}, {'cid': ' <pic2@x> '}]}, ['cid:pic2@x']), {'resolved': [['cid:pic2@x', 1]], 'root': 0, 'unused': []}), ('scheme casing', ({'parts': [{'cid': '<root@x>'}, {'cid': '<pic@x>'}]}, ['CID:pic@x', 'Cid:pic@x', 'http://pic@x']), {'resolved': [['CID:pic@x', 1], ['Cid:pic@x', 1], ['http://pic@x', None]], 'root': 0, 'unused': []}), ('percent-encoded reference', ({'parts': [{}, {'cid': '<a+b2@x>'}]}, ['cid:a%2Bb2%40x']), {'resolved': [['cid:a%2Bb2%40x', 1]], 'root': 0, 'unused': []}), ('root referenced by itself', ({'params': {'start': '<root@x>'}, 'parts': [{'cid': '<pic@x>'}, {'cid': '<root@x>'}]}, ['cid:root@x', 'cid:pic@x']), {'resolved': [['cid:root@x', None], ['cid:pic@x', 0]], 'root': 1, 'unused': []}), ('no start and an id-less part', ({'params': {}, 'parts': [{'cid': '<doc@x>'}, {}, {'cid': '<p2@x>'}]}, ['cid:p2@x']), {'resolved': [['cid:p2@x', 2]], 'root': 0, 'unused': [1]}), ('unused parts with late root', ({'params': {'start': '<r@x>'}, 'parts': [{'cid': '<a@x>'}, {'cid': '<b@x>'}, {'cid': '<r@x>'}]}, ['cid:a@x']), {'resolved': [['cid:a@x', 0]], 'root': 2, 'unused': [1]})], 3: [('padded content id', ({'parts': [{'cid': '<root@x>'}, {'cid': ' <pic3@x> '}]}, ['cid:pic3@x']), {'resolved': [['cid:pic3@x', 1]], 'root': 0, 'unused': []}), ('scheme casing', ({'parts': [{'cid': '<root@x>'}, {'cid': '<pic@x>'}]}, ['CID:pic@x', 'Cid:pic@x', 'http://pic@x']), {'resolved': [['CID:pic@x', 1], ['Cid:pic@x', 1], ['http://pic@x', None]], 'root': 0, 'unused': []}), ('percent-encoded reference', ({'parts': [{}, {'cid': '<a+b3@x>'}]}, ['cid:a%2Bb3%40x']), {'resolved': [['cid:a%2Bb3%40x', 1]], 'root': 0, 'unused': []}), ('root referenced by itself', ({'params': {'start': '<root@x>'}, 'parts': [{'cid': '<pic@x>'}, {'cid': '<root@x>'}]}, ['cid:root@x', 'cid:pic@x']), {'resolved': [['cid:root@x', None], ['cid:pic@x', 0]], 'root': 1, 'unused': []}), ('no start and an id-less part', ({'params': {}, 'parts': [{'cid': '<doc@x>'}, {}, {'cid': '<p3@x>'}]}, ['cid:p3@x']), {'resolved': [['cid:p3@x', 2]], 'root': 0, 'unused': [1]}), ('unused parts with late root', ({'params': {'start': '<r@x>'}, 'parts': [{'cid': '<a@x>'}, {'cid': '<b@x>'}, {'cid': '<r@x>'}]}, ['cid:a@x']), {'resolved': [['cid:a@x', 0]], 'root': 2, 'unused': [1]})], 4: [('padded content id', ({'parts': [{'cid': '<root@x>'}, {'cid': ' <pic4@x> '}]}, ['cid:pic4@x']), {'resolved': [['cid:pic4@x', 1]], 'root': 0, 'unused': []}), ('scheme casing', ({'parts': [{'cid': '<root@x>'}, {'cid': '<pic@x>'}]}, ['CID:pic@x', 'Cid:pic@x', 'http://pic@x']), {'resolved': [['CID:pic@x', 1], ['Cid:pic@x', 1], ['http://pic@x', None]], 'root': 0, 'unused': []}), ('percent-encoded reference', ({'parts': [{}, {'cid': '<a+b4@x>'}]}, ['cid:a%2Bb4%40x']), {'resolved': [['cid:a%2Bb4%40x', 1]], 'root': 0, 'unused': []}), ('root referenced by itself', ({'params': {'start': '<root@x>'}, 'parts': [{'cid': '<pic@x>'}, {'cid': '<root@x>'}]}, ['cid:root@x', 'cid:pic@x']), {'resolved': [['cid:root@x', None], ['cid:pic@x', 0]], 'root': 1, 'unused': []}), ('no start and an id-less part', ({'params': {}, 'parts': [{'cid': '<doc@x>'}, {}, {'cid': '<p4@x>'}]}, ['cid:p4@x']), {'resolved': [['cid:p4@x', 2]], 'root': 0, 'unused': [1]}), ('unused parts with late root', ({'params': {'start': '<r@x>'}, 'parts': [{'cid': '<a@x>'}, {'cid': '<b@x>'}, {'cid': '<r@x>'}]}, ['cid:a@x']), {'resolved': [['cid:a@x', 0]], 'root': 2, 'unused': [1]})], 5: [('padded content id', ({'parts': [{'cid': '<root@x>'}, {'cid': ' <pic5@x> '}]}, ['cid:pic5@x']), {'resolved': [['cid:pic5@x', 1]], 'root': 0, 'unused': []}), ('scheme casing', ({'parts': [{'cid': '<root@x>'}, {'cid': '<pic@x>'}]}, ['CID:pic@x', 'Cid:pic@x', 'http://pic@x']), {'resolved': [['CID:pic@x', 1], ['Cid:pic@x', 1], ['http://pic@x', None]], 'root': 0, 'unused': []}), ('percent-encoded reference', ({'parts': [{}, {'cid': '<a+b5@x>'}]}, ['cid:a%2Bb5%40x']), {'resolved': [['cid:a%2Bb5%40x', 1]], 'root': 0, 'unused': []}), ('root referenced by itself', ({'params': {'start': '<root@x>'}, 'parts': [{'cid': '<pic@x>'}, {'cid': '<root@x>'}]}, ['cid:root@x', 'cid:pic@x']), {'resolved': [['cid:root@x', None], ['cid:pic@x', 0]], 'root': 1, 'unused': []}), ('no start and an id-less part', ({'params': {}, 'parts': [{'cid': '<doc@x>'}, {}, {'cid': '<p5@x>'}]}, ['cid:p5@x']), {'resolved': [['cid:p5@x', 2]], 'root': 0, 'unused': [1]}), ('unused parts with late root', ({'params': {'start': '<r@x>'}, 'parts': [{'cid': '<a@x>'}, {'cid': '<b@x>'}, {'cid': '<r@x>'}]}, ['cid:a@x']), {'resolved': [['cid:a@x', 0]], 'root': 2, 'unused': [1]})]}
for _label, _args, _expected in _CASES[N]:
    check(_label, solve(*_args), _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
padded content id{'resolved': [['cid:pic1@x', 1]], 'root': 0, 'unused': []}{'resolved': [['cid:pic1@x', 1]], 'root': 0, 'unused': []}Passed
scheme casing{'resolved': [['CID:pic@x', 1], ['Cid:pic@x', 1], ['http://pic@x', None]], 'root': 0, 'unused': []}{'resolved': [['CID:pic@x', 1], ['Cid:pic@x', 1], ['http://pic@x', None]], 'root': 0, 'unused': []}Passed
percent-encoded reference{'resolved': [['cid:a%2Bb1%40x', 1]], 'root': 0, 'unused': []}{'resolved': [['cid:a%2Bb1%40x', 1]], 'root': 0, 'unused': []}Passed
root referenced by itself{'resolved': [['cid:root@x', None], ['cid:pic@x', 0]], 'root': 1, 'unused': []}{'resolved': [['cid:root@x', None], ['cid:pic@x', 0]], 'root': 1, 'unused': []}Passed
no start and an id-less part{'resolved': [['cid:p1@x', 2]], 'root': 0, 'unused': [1]}{'resolved': [['cid:p1@x', 2]], 'root': 0, 'unused': [1]}Passed
unused parts with late root{'resolved': [['cid:a@x', 0]], 'root': 2, 'unused': [1]}{'resolved': [['cid:a@x', 0]], 'root': 2, 'unused': [1]}Passed

SHA-256 / 4cb75440b3f124aed8eb5ecd5ddc8bb745872d6c02cc6c24872ee2e7cfc85d49

Verification & scope

Stipulated offline model over pre-parsed MIME dictionaries; not a conforming MIME parser, generator or mail client. 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:49:16.627690+00:00.

Case digest / f085488bef50ed49fd11d73e5164831e7db8278d4b997f6fdc1525d9dc1c0159