Skip to content

fix: conformance tool Windows crash + remove redundant mediaType from local-business example - #69

Open
hammer-build wants to merge 1 commit into
ards-project:mainfrom
hammer-build:fix/conformance-windows-unicode-and-local-business-mediatype
Open

fix: conformance tool Windows crash + remove redundant mediaType from local-business example#69
hammer-build wants to merge 1 commit into
ards-project:mainfrom
hammer-build:fix/conformance-windows-unicode-and-local-business-mediatype

Conversation

@hammer-build

Copy link
Copy Markdown

What this fixes

Two independent issues found while running the conformance tool against the new example catalogs on Windows.


1. Conformance tool crashes on Windows (conformance/bin/conformance-test)

Problem: The tool uses , , and for output. Windows terminals default to cp1252 encoding which cannot encode these characters — the tool crashes immediately before validating anything, printing a UnicodeEncodeError traceback.

Fix: Reconfigure stdout/stderr to UTF-8 at startup:

if hasattr(sys.stdout, 'reconfigure'):
    sys.stdout.reconfigure(encoding='utf-8', errors='replace')
    sys.stderr.reconfigure(encoding='utf-8', errors='replace')

reconfigure is available from Python 3.7+. The call is a no-op on terminals already in UTF-8 mode (Linux, macOS), so cross-platform behaviour is unchanged.

2. Redundant mediaType field in local-business example

Problem: Both entries in local-business-catalog.json have a top-level mediaType field that duplicates type:

"type": "application/a2a-agent-card+json",
"mediaType": "application/a2a-agent-card+json"

mediaType at entry level is not part of the ARD spec — type already carries the IANA media type. It is absent from all other catalog examples (basic, fda-ndc, noaa-weather). As a teaching example, having an extra non-spec field risks confusing readers.

Fix: Remove both occurrences. All conformance checks still pass.

Testing: Verified on Windows (Python 3.13, cp1252 terminal) without setting PYTHONIOENCODING:

python conformance/bin/conformance-test manifest conformance/examples/local-business/local-business-catalog.jsonCONFORMANCE STATUS: PASS  (exit 0)

conformance/bin/conformance-test: reconfigure stdout/stderr to UTF-8 on
startup so the tool no longer crashes on Windows (cp1252 default cannot
encode the check/cross/warning symbols). Uses sys.stdout.reconfigure
which is a no-op on Python < 3.7 and on terminals already in UTF-8 mode,
so Linux/macOS behaviour is unchanged.

conformance/examples/local-business/local-business-catalog.json: remove
the redundant top-level `mediaType` field from both entries. The `type`
field already carries the IANA media type; `mediaType` at entry level is
not part of the ARD spec and was absent from all other catalog examples.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant