FAILURE MAP
← Case archive

FA-76741 / Email MIME structure / Open access

Detect a calendar invitation inside a message: no descent into messages · case 01

An invitation inside a forwarded message is offered to the reader as if it were addressed to them.

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

ROOT CAUSE

The no descent into messages decision evaluates `if t == 'message/rfc822': walk(n['body']) return` where the contract requires `if t == 'message/rfc822': return`.

VERIFIED REPAIR

Use `if t == 'message/rfc822': return` for the no descent into messages decision and keep every other rule of the model unchanged.

Unsuccessful approach: Descending only into inline forwarded messages still exposes their invitations. The attempted `if t == 'message/rfc822': if (n.get('disp') or '').lower() != 'attachment': walk(n['body']) return` 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':
            walk(n['body'])
            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': 1, 'method': 'REQUEST'}{'attachments_ics': 0, 'count': 0, 'method': None}Failed
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 / 4aff1564532aeb85b3bfc650a923385a20681607736d6ad6d6bd7e534905f169

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':
            if (n.get('disp') or '').lower() != 'attachment':
                walk(n['body'])
            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': 1, 'method': 'REQUEST'}{'attachments_ics': 0, 'count': 0, 'method': None}Failed
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 / fdcba2a00e3e6ac50e3ebdd0039d59ecf485bdc571580de558f57a4bd56eca93

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

Case digest / 10b3958b3b5cfd5e17bc2638a7874c9067dd2111979361e8a1390180f50bdcfc