FAILURE MAP
← Case archive

FA-76756 / Email MIME structure / Open access

Detect a calendar invitation inside a message: ambiguity · case 01

Conflicting REQUEST and CANCEL parts are resolved silently to one of them.

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

ROOT CAUSE

The ambiguity decision evaluates `distinct[0]` where the contract requires `distinct[0] if len(distinct) == 1 else 'AMBIGUOUS'`.

VERIFIED REPAIR

Use `distinct[0] if len(distinct) == 1 else 'AMBIGUOUS'` for the ambiguity decision and keep every other rule of the model unchanged.

Unsuccessful approach: Counting parts instead of distinct methods calls a repeated method ambiguous. The attempted `distinct[0] if len(methods) == 1 else 'AMBIGUOUS'` still disagrees with a fixture.

Case contract

Walk multiparts but never descend into message/rfc822 parts. A text/calendar part, or any part whose filename ends in ".ics" (case-insensitive), with an attachment disposition only counts as an attached .ics file. Other text/calendar parts with a method parameter contribute their method (trimmed, upper-cased; parameter names case-insensitive). Result {method: the single distinct method, "AMBIGUOUS" for several, None for none; count: contributing parts; attachments_ics}.

Why this case matters

Clients show accept/decline controls only for real invitations addressed to the reader.

1 / The failure

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

N = 1
observations = []
def solve(tree):
    methods = []
    ics = 0
    def walk(n):
        nonlocal ics
        t = n['type'].lower()
        if t.startswith('multipart/'):
            for c in n['parts']:
                walk(c)
            return
        if t == 'message/rfc822':
            return
        disp = (n.get('disp') or '').lower()
        if t == 'text/calendar' or (n.get('filename') or '').lower().endswith('.ics'):
            if disp == 'attachment':
                ics += 1
                return
            if t == 'text/calendar':
                params = {k.lower(): v for k, v in n.get('params', {}).items()}
                if params.get('method'):
                    methods.append(params['method'].strip().upper())
    walk(tree)
    distinct = sorted(set(methods))
    method = None if not distinct else (distinct[0])
    return {'method': method, 'count': len(methods), 'attachments_ics': ics}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('forwarded invitation', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'message/rfc822', 'body': {'type': 'text/calendar', 'params': {'method': 'REQUEST'}}}]},), {'attachments_ics': 0, 'count': 0, 'method': None}), ('attached calendar with method', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'PUBLISH'}, 'disp': 'attachment', 'filename': 'e1.ics'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('padded lower-case method', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'Method': ' request '}}]},), {'attachments_ics': 0, 'count': 1, 'method': 'REQUEST'}), ('conflicting methods', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/calendar', 'params': {'method': 'REQUEST'}}, {'type': 'text/calendar', 'params': {'method': 'CANCEL'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'AMBIGUOUS'}), ('same method twice', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'REPLY'}}, {'type': 'text/calendar', 'params': {'method': 'reply'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'REPLY'}), ('upper-case ics attachment', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'INVITE1.ICS', 'disp': 'attachment'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('plain message', ({'type': 'text/plain'},), {'attachments_ics': 0, 'count': 0, 'method': None})], 2: [('forwarded invitation', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'message/rfc822', 'body': {'type': 'text/calendar', 'params': {'method': 'REQUEST'}}}]},), {'attachments_ics': 0, 'count': 0, 'method': None}), ('attached calendar with method', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'PUBLISH'}, 'disp': 'attachment', 'filename': 'e2.ics'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('padded lower-case method', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'Method': ' request '}}]},), {'attachments_ics': 0, 'count': 1, 'method': 'REQUEST'}), ('conflicting methods', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/calendar', 'params': {'method': 'REQUEST'}}, {'type': 'text/calendar', 'params': {'method': 'CANCEL'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'AMBIGUOUS'}), ('same method twice', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'REPLY'}}, {'type': 'text/calendar', 'params': {'method': 'reply'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'REPLY'}), ('upper-case ics attachment', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'INVITE2.ICS', 'disp': 'attachment'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('plain message', ({'type': 'text/plain'},), {'attachments_ics': 0, 'count': 0, 'method': None})], 3: [('forwarded invitation', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'message/rfc822', 'body': {'type': 'text/calendar', 'params': {'method': 'REQUEST'}}}]},), {'attachments_ics': 0, 'count': 0, 'method': None}), ('attached calendar with method', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'PUBLISH'}, 'disp': 'attachment', 'filename': 'e3.ics'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('padded lower-case method', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'Method': ' request '}}]},), {'attachments_ics': 0, 'count': 1, 'method': 'REQUEST'}), ('conflicting methods', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/calendar', 'params': {'method': 'REQUEST'}}, {'type': 'text/calendar', 'params': {'method': 'CANCEL'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'AMBIGUOUS'}), ('same method twice', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'REPLY'}}, {'type': 'text/calendar', 'params': {'method': 'reply'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'REPLY'}), ('upper-case ics attachment', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'INVITE3.ICS', 'disp': 'attachment'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('plain message', ({'type': 'text/plain'},), {'attachments_ics': 0, 'count': 0, 'method': None})], 4: [('forwarded invitation', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'message/rfc822', 'body': {'type': 'text/calendar', 'params': {'method': 'REQUEST'}}}]},), {'attachments_ics': 0, 'count': 0, 'method': None}), ('attached calendar with method', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'PUBLISH'}, 'disp': 'attachment', 'filename': 'e4.ics'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('padded lower-case method', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'Method': ' request '}}]},), {'attachments_ics': 0, 'count': 1, 'method': 'REQUEST'}), ('conflicting methods', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/calendar', 'params': {'method': 'REQUEST'}}, {'type': 'text/calendar', 'params': {'method': 'CANCEL'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'AMBIGUOUS'}), ('same method twice', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'REPLY'}}, {'type': 'text/calendar', 'params': {'method': 'reply'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'REPLY'}), ('upper-case ics attachment', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'INVITE4.ICS', 'disp': 'attachment'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('plain message', ({'type': 'text/plain'},), {'attachments_ics': 0, 'count': 0, 'method': None})], 5: [('forwarded invitation', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'message/rfc822', 'body': {'type': 'text/calendar', 'params': {'method': 'REQUEST'}}}]},), {'attachments_ics': 0, 'count': 0, 'method': None}), ('attached calendar with method', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'PUBLISH'}, 'disp': 'attachment', 'filename': 'e5.ics'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('padded lower-case method', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'Method': ' request '}}]},), {'attachments_ics': 0, 'count': 1, 'method': 'REQUEST'}), ('conflicting methods', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/calendar', 'params': {'method': 'REQUEST'}}, {'type': 'text/calendar', 'params': {'method': 'CANCEL'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'AMBIGUOUS'}), ('same method twice', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'REPLY'}}, {'type': 'text/calendar', 'params': {'method': 'reply'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'REPLY'}), ('upper-case ics attachment', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'INVITE5.ICS', 'disp': 'attachment'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('plain message', ({'type': 'text/plain'},), {'attachments_ics': 0, 'count': 0, 'method': None})]}
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
forwarded invitation{'attachments_ics': 0, 'count': 0, 'method': None}{'attachments_ics': 0, 'count': 0, 'method': None}Passed
attached calendar with method{'attachments_ics': 1, 'count': 0, 'method': None}{'attachments_ics': 1, 'count': 0, 'method': None}Passed
padded lower-case method{'attachments_ics': 0, 'count': 1, 'method': 'REQUEST'}{'attachments_ics': 0, 'count': 1, 'method': 'REQUEST'}Passed
conflicting methods{'attachments_ics': 0, 'count': 2, 'method': 'CANCEL'}{'attachments_ics': 0, 'count': 2, 'method': 'AMBIGUOUS'}Failed
same method twice{'attachments_ics': 0, 'count': 2, 'method': 'REPLY'}{'attachments_ics': 0, 'count': 2, 'method': 'REPLY'}Passed
upper-case ics attachment{'attachments_ics': 1, 'count': 0, 'method': None}{'attachments_ics': 1, 'count': 0, 'method': None}Passed
plain message{'attachments_ics': 0, 'count': 0, 'method': None}{'attachments_ics': 0, 'count': 0, 'method': None}Passed

SHA-256 / c704fb435bc856270683d8d965b05eaa4c009ee7777a46c35f3d8481ca17a9f5

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(tree):
    methods = []
    ics = 0
    def walk(n):
        nonlocal ics
        t = n['type'].lower()
        if t.startswith('multipart/'):
            for c in n['parts']:
                walk(c)
            return
        if t == 'message/rfc822':
            return
        disp = (n.get('disp') or '').lower()
        if t == 'text/calendar' or (n.get('filename') or '').lower().endswith('.ics'):
            if disp == 'attachment':
                ics += 1
                return
            if t == 'text/calendar':
                params = {k.lower(): v for k, v in n.get('params', {}).items()}
                if params.get('method'):
                    methods.append(params['method'].strip().upper())
    walk(tree)
    distinct = sorted(set(methods))
    method = None if not distinct else (distinct[0] if len(methods) == 1 else 'AMBIGUOUS')
    return {'method': method, 'count': len(methods), 'attachments_ics': ics}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('forwarded invitation', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'message/rfc822', 'body': {'type': 'text/calendar', 'params': {'method': 'REQUEST'}}}]},), {'attachments_ics': 0, 'count': 0, 'method': None}), ('attached calendar with method', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'PUBLISH'}, 'disp': 'attachment', 'filename': 'e1.ics'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('padded lower-case method', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'Method': ' request '}}]},), {'attachments_ics': 0, 'count': 1, 'method': 'REQUEST'}), ('conflicting methods', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/calendar', 'params': {'method': 'REQUEST'}}, {'type': 'text/calendar', 'params': {'method': 'CANCEL'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'AMBIGUOUS'}), ('same method twice', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'REPLY'}}, {'type': 'text/calendar', 'params': {'method': 'reply'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'REPLY'}), ('upper-case ics attachment', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'INVITE1.ICS', 'disp': 'attachment'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('plain message', ({'type': 'text/plain'},), {'attachments_ics': 0, 'count': 0, 'method': None})], 2: [('forwarded invitation', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'message/rfc822', 'body': {'type': 'text/calendar', 'params': {'method': 'REQUEST'}}}]},), {'attachments_ics': 0, 'count': 0, 'method': None}), ('attached calendar with method', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'PUBLISH'}, 'disp': 'attachment', 'filename': 'e2.ics'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('padded lower-case method', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'Method': ' request '}}]},), {'attachments_ics': 0, 'count': 1, 'method': 'REQUEST'}), ('conflicting methods', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/calendar', 'params': {'method': 'REQUEST'}}, {'type': 'text/calendar', 'params': {'method': 'CANCEL'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'AMBIGUOUS'}), ('same method twice', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'REPLY'}}, {'type': 'text/calendar', 'params': {'method': 'reply'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'REPLY'}), ('upper-case ics attachment', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'INVITE2.ICS', 'disp': 'attachment'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('plain message', ({'type': 'text/plain'},), {'attachments_ics': 0, 'count': 0, 'method': None})], 3: [('forwarded invitation', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'message/rfc822', 'body': {'type': 'text/calendar', 'params': {'method': 'REQUEST'}}}]},), {'attachments_ics': 0, 'count': 0, 'method': None}), ('attached calendar with method', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'PUBLISH'}, 'disp': 'attachment', 'filename': 'e3.ics'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('padded lower-case method', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'Method': ' request '}}]},), {'attachments_ics': 0, 'count': 1, 'method': 'REQUEST'}), ('conflicting methods', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/calendar', 'params': {'method': 'REQUEST'}}, {'type': 'text/calendar', 'params': {'method': 'CANCEL'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'AMBIGUOUS'}), ('same method twice', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'REPLY'}}, {'type': 'text/calendar', 'params': {'method': 'reply'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'REPLY'}), ('upper-case ics attachment', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'INVITE3.ICS', 'disp': 'attachment'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('plain message', ({'type': 'text/plain'},), {'attachments_ics': 0, 'count': 0, 'method': None})], 4: [('forwarded invitation', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'message/rfc822', 'body': {'type': 'text/calendar', 'params': {'method': 'REQUEST'}}}]},), {'attachments_ics': 0, 'count': 0, 'method': None}), ('attached calendar with method', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'PUBLISH'}, 'disp': 'attachment', 'filename': 'e4.ics'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('padded lower-case method', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'Method': ' request '}}]},), {'attachments_ics': 0, 'count': 1, 'method': 'REQUEST'}), ('conflicting methods', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/calendar', 'params': {'method': 'REQUEST'}}, {'type': 'text/calendar', 'params': {'method': 'CANCEL'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'AMBIGUOUS'}), ('same method twice', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'REPLY'}}, {'type': 'text/calendar', 'params': {'method': 'reply'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'REPLY'}), ('upper-case ics attachment', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'INVITE4.ICS', 'disp': 'attachment'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('plain message', ({'type': 'text/plain'},), {'attachments_ics': 0, 'count': 0, 'method': None})], 5: [('forwarded invitation', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'message/rfc822', 'body': {'type': 'text/calendar', 'params': {'method': 'REQUEST'}}}]},), {'attachments_ics': 0, 'count': 0, 'method': None}), ('attached calendar with method', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'PUBLISH'}, 'disp': 'attachment', 'filename': 'e5.ics'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('padded lower-case method', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'Method': ' request '}}]},), {'attachments_ics': 0, 'count': 1, 'method': 'REQUEST'}), ('conflicting methods', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/calendar', 'params': {'method': 'REQUEST'}}, {'type': 'text/calendar', 'params': {'method': 'CANCEL'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'AMBIGUOUS'}), ('same method twice', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'REPLY'}}, {'type': 'text/calendar', 'params': {'method': 'reply'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'REPLY'}), ('upper-case ics attachment', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'INVITE5.ICS', 'disp': 'attachment'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('plain message', ({'type': 'text/plain'},), {'attachments_ics': 0, 'count': 0, 'method': None})]}
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
forwarded invitation{'attachments_ics': 0, 'count': 0, 'method': None}{'attachments_ics': 0, 'count': 0, 'method': None}Passed
attached calendar with method{'attachments_ics': 1, 'count': 0, 'method': None}{'attachments_ics': 1, 'count': 0, 'method': None}Passed
padded lower-case method{'attachments_ics': 0, 'count': 1, 'method': 'REQUEST'}{'attachments_ics': 0, 'count': 1, 'method': 'REQUEST'}Passed
conflicting methods{'attachments_ics': 0, 'count': 2, 'method': 'AMBIGUOUS'}{'attachments_ics': 0, 'count': 2, 'method': 'AMBIGUOUS'}Passed
same method twice{'attachments_ics': 0, 'count': 2, 'method': 'AMBIGUOUS'}{'attachments_ics': 0, 'count': 2, 'method': 'REPLY'}Failed
upper-case ics attachment{'attachments_ics': 1, 'count': 0, 'method': None}{'attachments_ics': 1, 'count': 0, 'method': None}Passed
plain message{'attachments_ics': 0, 'count': 0, 'method': None}{'attachments_ics': 0, 'count': 0, 'method': None}Passed

SHA-256 / b3b27c607b68d2e37743096db0d04afc381cc2ef3889d4a2f90771aef63e54a1

3 / The verified repair

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

N = 1
observations = []
def solve(tree):
    methods = []
    ics = 0
    def walk(n):
        nonlocal ics
        t = n['type'].lower()
        if t.startswith('multipart/'):
            for c in n['parts']:
                walk(c)
            return
        if t == 'message/rfc822':
            return
        disp = (n.get('disp') or '').lower()
        if t == 'text/calendar' or (n.get('filename') or '').lower().endswith('.ics'):
            if disp == 'attachment':
                ics += 1
                return
            if t == 'text/calendar':
                params = {k.lower(): v for k, v in n.get('params', {}).items()}
                if params.get('method'):
                    methods.append(params['method'].strip().upper())
    walk(tree)
    distinct = sorted(set(methods))
    method = None if not distinct else (distinct[0] if len(distinct) == 1 else 'AMBIGUOUS')
    return {'method': method, 'count': len(methods), 'attachments_ics': ics}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('forwarded invitation', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'message/rfc822', 'body': {'type': 'text/calendar', 'params': {'method': 'REQUEST'}}}]},), {'attachments_ics': 0, 'count': 0, 'method': None}), ('attached calendar with method', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'PUBLISH'}, 'disp': 'attachment', 'filename': 'e1.ics'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('padded lower-case method', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'Method': ' request '}}]},), {'attachments_ics': 0, 'count': 1, 'method': 'REQUEST'}), ('conflicting methods', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/calendar', 'params': {'method': 'REQUEST'}}, {'type': 'text/calendar', 'params': {'method': 'CANCEL'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'AMBIGUOUS'}), ('same method twice', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'REPLY'}}, {'type': 'text/calendar', 'params': {'method': 'reply'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'REPLY'}), ('upper-case ics attachment', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'INVITE1.ICS', 'disp': 'attachment'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('plain message', ({'type': 'text/plain'},), {'attachments_ics': 0, 'count': 0, 'method': None})], 2: [('forwarded invitation', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'message/rfc822', 'body': {'type': 'text/calendar', 'params': {'method': 'REQUEST'}}}]},), {'attachments_ics': 0, 'count': 0, 'method': None}), ('attached calendar with method', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'PUBLISH'}, 'disp': 'attachment', 'filename': 'e2.ics'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('padded lower-case method', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'Method': ' request '}}]},), {'attachments_ics': 0, 'count': 1, 'method': 'REQUEST'}), ('conflicting methods', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/calendar', 'params': {'method': 'REQUEST'}}, {'type': 'text/calendar', 'params': {'method': 'CANCEL'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'AMBIGUOUS'}), ('same method twice', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'REPLY'}}, {'type': 'text/calendar', 'params': {'method': 'reply'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'REPLY'}), ('upper-case ics attachment', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'INVITE2.ICS', 'disp': 'attachment'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('plain message', ({'type': 'text/plain'},), {'attachments_ics': 0, 'count': 0, 'method': None})], 3: [('forwarded invitation', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'message/rfc822', 'body': {'type': 'text/calendar', 'params': {'method': 'REQUEST'}}}]},), {'attachments_ics': 0, 'count': 0, 'method': None}), ('attached calendar with method', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'PUBLISH'}, 'disp': 'attachment', 'filename': 'e3.ics'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('padded lower-case method', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'Method': ' request '}}]},), {'attachments_ics': 0, 'count': 1, 'method': 'REQUEST'}), ('conflicting methods', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/calendar', 'params': {'method': 'REQUEST'}}, {'type': 'text/calendar', 'params': {'method': 'CANCEL'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'AMBIGUOUS'}), ('same method twice', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'REPLY'}}, {'type': 'text/calendar', 'params': {'method': 'reply'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'REPLY'}), ('upper-case ics attachment', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'INVITE3.ICS', 'disp': 'attachment'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('plain message', ({'type': 'text/plain'},), {'attachments_ics': 0, 'count': 0, 'method': None})], 4: [('forwarded invitation', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'message/rfc822', 'body': {'type': 'text/calendar', 'params': {'method': 'REQUEST'}}}]},), {'attachments_ics': 0, 'count': 0, 'method': None}), ('attached calendar with method', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'PUBLISH'}, 'disp': 'attachment', 'filename': 'e4.ics'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('padded lower-case method', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'Method': ' request '}}]},), {'attachments_ics': 0, 'count': 1, 'method': 'REQUEST'}), ('conflicting methods', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/calendar', 'params': {'method': 'REQUEST'}}, {'type': 'text/calendar', 'params': {'method': 'CANCEL'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'AMBIGUOUS'}), ('same method twice', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'REPLY'}}, {'type': 'text/calendar', 'params': {'method': 'reply'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'REPLY'}), ('upper-case ics attachment', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'INVITE4.ICS', 'disp': 'attachment'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('plain message', ({'type': 'text/plain'},), {'attachments_ics': 0, 'count': 0, 'method': None})], 5: [('forwarded invitation', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'message/rfc822', 'body': {'type': 'text/calendar', 'params': {'method': 'REQUEST'}}}]},), {'attachments_ics': 0, 'count': 0, 'method': None}), ('attached calendar with method', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'PUBLISH'}, 'disp': 'attachment', 'filename': 'e5.ics'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('padded lower-case method', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'Method': ' request '}}]},), {'attachments_ics': 0, 'count': 1, 'method': 'REQUEST'}), ('conflicting methods', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/calendar', 'params': {'method': 'REQUEST'}}, {'type': 'text/calendar', 'params': {'method': 'CANCEL'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'AMBIGUOUS'}), ('same method twice', ({'type': 'multipart/alternative', 'parts': [{'type': 'text/plain'}, {'type': 'text/calendar', 'params': {'method': 'REPLY'}}, {'type': 'text/calendar', 'params': {'method': 'reply'}}]},), {'attachments_ics': 0, 'count': 2, 'method': 'REPLY'}), ('upper-case ics attachment', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'INVITE5.ICS', 'disp': 'attachment'}]},), {'attachments_ics': 1, 'count': 0, 'method': None}), ('plain message', ({'type': 'text/plain'},), {'attachments_ics': 0, 'count': 0, 'method': None})]}
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
forwarded invitation{'attachments_ics': 0, 'count': 0, 'method': None}{'attachments_ics': 0, 'count': 0, 'method': None}Passed
attached calendar with method{'attachments_ics': 1, 'count': 0, 'method': None}{'attachments_ics': 1, 'count': 0, 'method': None}Passed
padded lower-case method{'attachments_ics': 0, 'count': 1, 'method': 'REQUEST'}{'attachments_ics': 0, 'count': 1, 'method': 'REQUEST'}Passed
conflicting methods{'attachments_ics': 0, 'count': 2, 'method': 'AMBIGUOUS'}{'attachments_ics': 0, 'count': 2, 'method': 'AMBIGUOUS'}Passed
same method twice{'attachments_ics': 0, 'count': 2, 'method': 'REPLY'}{'attachments_ics': 0, 'count': 2, 'method': 'REPLY'}Passed
upper-case ics attachment{'attachments_ics': 1, 'count': 0, 'method': None}{'attachments_ics': 1, 'count': 0, 'method': None}Passed
plain message{'attachments_ics': 0, 'count': 0, 'method': None}{'attachments_ics': 0, 'count': 0, 'method': None}Passed

SHA-256 / b31861e0bcfa7907c0e037efe7e5e9749128a941a1a4584eeeac37fa5046b83a

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:19.220703+00:00.

Case digest / f22548b919dd505c040f6362df0c07518140f6a45290ea7c6d38b0490b3f35df