Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions API_REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Complete API documentation for the vCon library - a Python implementation of the
| --- | --- |
| `add_tag()` wrote `party: 0` even with no parties | `add_tag(name, value, party=None)`; `party` defaults to 0. On a vCon with no parties it still writes party 0 but emits a `DeprecationWarning` (it will raise in 1.1); a `party` index out of range raises `ValueError` |
| `add_wtf_transcription_attachment()` | deprecated (`DeprecationWarning`); use `add_wtf_transcription_analysis()`, which writes the analysis entry the WTF draft requires |
| `is_valid()` core structure only | also reports a malformed `content_hash` and errors in the body of every `lawful_basis` attachment; `get_validation_warnings()` adds a `url` without `content_hash` (an error from 1.1), JSON-string bodies under `encoding: "json"`, and lawful-basis warnings |
| `is_valid()` core structure only | also reports a malformed `content_hash` and errors in the body of every `lawful_basis` attachment; `get_validation_warnings()` adds JSON-string bodies under `encoding: "json"`, and lawful-basis warnings |
| loading rewrote `created_at` (and crashed on an unparseable one) | `created_at` is kept exactly as written; `is_valid()` reports an unparseable value |
| `Dialog.add_inline_data(body: str, ...)` | also accepts `bytes` (encoded to base64url); `content_hash` is over the decoded content |
| `generate_thumbnail()` defined twice (the image one won) | dispatches to `generate_image_thumbnail()` or `generate_video_thumbnail()`; video helpers need `pip install "vcon[video]"` and the ffmpeg binary |
Expand Down Expand Up @@ -416,7 +416,7 @@ is_valid, errors = vcon.is_valid()
```

###### `get_validation_warnings() -> List[str]`
Findings that do not make the vCon invalid, for example a `url` without a `content_hash` on a dialog, attachment or analysis entry (a MUST in core-05, reported as a warning in 1.0.x and an `is_valid()` error from vcon 1.1), an `encoding: "json"` body that is a serialized JSON string, and lawful-basis warnings (an unknown proof type, hash algorithm or canonicalization method is a warning, since the draft's lists are open).
Findings that do not make the vCon invalid, for example an `encoding: "json"` body that is a serialized JSON string, and lawful-basis warnings (an unknown proof type, hash algorithm or canonicalization method is a warning, since the draft's lists are open). A `url` without a `content_hash` is allowed on a dialog, attachment or analysis entry (from 1.0.6; earlier 1.0.x releases warned), because a producer cannot always get stable bytes for it, such as a YouTube page or audio behind a login. `redacted_from` and `amended_from` still need a `content_hash` with a `url`.

```python
warnings = vcon.get_validation_warnings()
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## [1.0.6] - 2026-11-20

### Changed
- A `url` without a `content_hash` is allowed on a Dialog, Attachment or
Analysis. A producer cannot always obtain stable bytes for the URL (a
streaming-service page such as YouTube, audio behind a login), so a hash
cannot be computed. This follows the working group's direction on
draft-ietf-vcon-vcon-core issue #40; core-05 itself still says MUST. 1.0.4
and 1.0.5 reported it as a warning and said it would become an error in
1.1; that plan is dropped. An Attachment needs `body`+`encoding` or `url`
(it used to need `url`+`content_hash`).
- Unchanged: a malformed `content_hash` is still an `is_valid()` error, and
`redacted_from` and `amended_from` still need a `content_hash` with a `url`.

## [1.0.5] - 2026-11-18

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ is_valid, errors = Vcon.validate_file("conversation.json")
is_valid, errors = Vcon.validate_json(json_string)
```

Besides the structure rules, `is_valid()` reports a malformed `content_hash` (it must be `<algorithm>-<unpadded base64url digest>`: 86 characters for sha512, 43 for sha256), an unparseable `created_at`, and problems in the body of every `lawful_basis` attachment (missing `lawful_basis`, `expiration`, `purpose_grants` and so on). `vcon.get_validation_warnings()` returns findings that do not make the vCon invalid: a `url` without a `content_hash` on a dialog, attachment or analysis entry (a warning in 1.0.x, an `is_valid()` error from vcon 1.1), an `encoding: "json"` body that is a serialized JSON string, and lawful-basis warnings (an unknown proof type, hash algorithm or canonicalization method is a warning, not an error). Loading a vCon keeps `created_at` exactly as written.
Besides the structure rules, `is_valid()` reports a malformed `content_hash` (it must be `<algorithm>-<unpadded base64url digest>`: 86 characters for sha512, 43 for sha256), an unparseable `created_at`, and problems in the body of every `lawful_basis` attachment (missing `lawful_basis`, `expiration`, `purpose_grants` and so on). `vcon.get_validation_warnings()` returns findings that do not make the vCon invalid: an `encoding: "json"` body that is a serialized JSON string, and lawful-basis warnings (an unknown proof type, hash algorithm or canonicalization method is a warning, not an error). Loading a vCon keeps `created_at` exactly as written. A `url` without a `content_hash` is allowed on a dialog, attachment or analysis entry (from 1.0.6; earlier 1.0.x releases warned), because a producer cannot always get stable bytes for it, such as a YouTube page or audio behind a login. `redacted_from` and `amended_from` still need a `content_hash` with a `url`.

### UUID Generation
```python
Expand Down
2 changes: 1 addition & 1 deletion LLM_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ is_valid, errors = Vcon.validate_json(json_string)
- an unparseable `created_at` (loading keeps `created_at` exactly as written and no longer reformats or rejects it)
- errors in the body of every `lawful_basis` attachment (missing `lawful_basis`, `expiration`, `purpose_grants` and so on)

`get_validation_warnings()` adds a `url` without a `content_hash` on a dialog, attachment or analysis entry (a MUST in core-05: a warning in 1.0.x, an `is_valid()` error from vcon 1.1, so always set `content_hash` with a `url`), an `encoding: "json"` body that is a serialized JSON string (pass the JSON value itself), and lawful-basis warnings; an unknown proof type, hash algorithm or canonicalization method is a warning, not an error.
Set `content_hash` with a `url` whenever you have the bytes (`compute_content_hash()`); it may be left out when you cannot get stable bytes, such as a YouTube page or audio behind a login, but `redacted_from` and `amended_from` always need it. `get_validation_warnings()` adds an `encoding: "json"` body that is a serialized JSON string (pass the JSON value itself), and lawful-basis warnings; an unknown proof type, hash algorithm or canonicalization method is a warning, not an error.

## Common Patterns and Best Practices

Expand Down
2 changes: 1 addition & 1 deletion MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
| `add_wtf_transcription_attachment()` | deprecated (`DeprecationWarning`): the WTF draft stores a transcription as analysis. Use `add_wtf_transcription_analysis(transcript, segments, metadata, dialog_index=None, session_index=None, **kwargs)`; read it back with `vcon.find_analysis_by_type("wtf_transcription")` instead of `find_wtf_attachments()` |
| `add_tag()` on a vCon with no parties wrote `party: 0` silently | still writes party 0, but emits a `DeprecationWarning` (the vCon fails `is_valid()`); it will raise `ValueError` in 1.1. Add a party before the first tag. New `party=` argument (default 0); an index out of range raises `ValueError` |
| `is_valid()` did not check `content_hash` or lawful-basis bodies | errors for a malformed `content_hash` (`<algorithm>-<unpadded base64url digest>`, 86 characters for sha512, 43 for sha256) and for problems in a `lawful_basis` attachment body. Unknown lawful-basis proof types, hash algorithms and canonicalization methods are warnings |
| no check for `url` without `content_hash` | reported by `get_validation_warnings()`; an `is_valid()` error from 1.1 |
| no check for `url` without `content_hash` | 1.0.4 and 1.0.5 warned; from 1.0.6 it is allowed on Dialog, Attachment and Analysis (still required on `redacted_from` and `amended_from`) |
| (no check) | `get_validation_warnings()` reports an `encoding: "json"` body that is a serialized JSON string |
| loading rewrote `created_at` into Python's ISO format (and an unparseable value crashed `Vcon()`) | `created_at` is kept exactly as written; `is_valid()` reports an unparseable value |
| `Dialog.add_inline_data()` took a str and hashed the base64url text | also takes `bytes` (encoded for you); `content_hash` is over the decoded content |
Expand Down
5 changes: 3 additions & 2 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ Reading and validating
Besides the structure and references, ``is_valid()`` checks that every
``content_hash`` has the form ``<algorithm>-<unpadded base64url digest>`` and
the body of every ``lawful_basis`` attachment. A ``url`` without a
``content_hash`` is reported by ``get_validation_warnings()`` in 1.0.x and
will be an error from 1.1. Loading keeps every value as written, including
``content_hash`` is allowed on a Dialog, Attachment or Analysis, because a
producer cannot always get stable bytes for it (a YouTube page, audio behind a
login); ``redacted_from`` and ``amended_from`` still need one. Loading keeps every value as written, including
timestamps, so an invalid ``created_at`` is reported by ``is_valid()`` rather
than raised.

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "vcon"
version = "1.0.5"
version = "1.0.6"
description = "The vCon library - vCon 0.5.0 (draft-ietf-vcon-vcon-core-05) specification implementation"
authors = ["Thomas McCarthy-Howe <ghostofbasho@gmail.com>"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="vcon",
version="1.0.5",
version="1.0.6",
author="Thomas McCarthy-Howe",
author_email="ghostofbasho@gmail.com",
description="The vCon library - vCon 0.5.0 (draft-ietf-vcon-vcon-core-05) specification implementation",
Expand Down
30 changes: 14 additions & 16 deletions src/vcon/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,16 @@ def content_hash_problems(value: Any) -> List[str]:
return problems


def _check_content(obj: Dict[str, Any], label: str, errors: List[str], warnings: List[str],
check_url: bool = True) -> None:
def _check_content(obj: Dict[str, Any], label: str, errors: List[str], warnings: List[str]) -> None:
"""Integrity and body-form checks shared by Dialog, Attachment, Analysis and the
redacted_from / amended_from references (section 2.4)."""
if check_url and "url" in obj and "content_hash" not in obj:
# A MUST in section 2.4. Reported as a warning in 1.0.x so producers
# that only hold a carrier URL keep validating; an error from 1.1.
warnings.append(
f"{label} has a url but no content_hash (an external reference MUST have both; "
"this will be an error in vcon 1.1)."
)
redacted_from / amended_from references (section 2.4).

A ``url`` without a ``content_hash`` is allowed on Dialog, Attachment and
Analysis: a producer cannot always obtain stable bytes for the URL (a
streaming-service page, audio behind a login). This follows the working
group's direction on draft-ietf-vcon-vcon-core issue #40; core-05 still
says MUST. ``redacted_from`` and ``amended_from`` keep the requirement.
"""
if "content_hash" in obj:
for problem in content_hash_problems(obj["content_hash"]):
errors.append(f"{label} has an invalid content_hash: {problem}.")
Expand Down Expand Up @@ -362,7 +361,7 @@ def validate_vcon_dict(
errors.append("redacted_from is missing required field: type")
if "url" in rf and "content_hash" not in rf:
errors.append("redacted_from with url must include content_hash.")
_check_content(rf, "redacted_from", errors, warnings, check_url=False)
_check_content(rf, "redacted_from", errors, warnings)
af = vcon.get("amended_from")
if "amended_from" in vcon:
if not isinstance(af, dict):
Expand All @@ -372,7 +371,7 @@ def validate_vcon_dict(
errors.append("amended_from must include uuid, or an external reference (url).")
if "url" in af and "content_hash" not in af:
errors.append("amended_from with url must include content_hash.")
_check_content(af, "amended_from", errors, warnings, check_url=False)
_check_content(af, "amended_from", errors, warnings)

# --- extensions / critical -------------------------------------------
ext_listed = vcon.get("extensions", [])
Expand Down Expand Up @@ -551,11 +550,10 @@ def validate_vcon_dict(
if "purpose" not in attachment:
errors.append(f"Attachment at index {i} is missing required field: purpose")
has_inline = "body" in attachment and "encoding" in attachment
has_external = "url" in attachment and "content_hash" in attachment
has_external = "url" in attachment
if not (has_inline or has_external or redacted):
errors.append(f"Attachment at index {i} must include body+encoding or url+content_hash.")
_check_content(attachment, f"Attachment at index {i}", errors, warnings,
check_url=has_inline or redacted)
errors.append(f"Attachment at index {i} must include body+encoding or url.")
_check_content(attachment, f"Attachment at index {i}", errors, warnings)
if "encoding" in attachment and attachment["encoding"] not in CORE_ENCODINGS and not ext_listed:
errors.append(f"Attachment at index {i} has invalid encoding: {attachment['encoding']}")
if "body" in attachment and attachment["body"] != "" and "mediatype" not in attachment:
Expand Down
20 changes: 15 additions & 5 deletions tests/test_fixes_1_0_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,21 @@ def _recording(**kw):


class TestContentHash:
def test_url_needs_content_hash(self):
def test_url_without_content_hash_is_allowed(self):
# 1.0.6: allowed on Dialog, Attachment and Analysis (WG direction on
# draft-ietf-vcon-vcon-core issue #40, e.g. a YouTube recording link).
v = _base()
v.add_dialog(_recording(url="https://example.com/a.wav"), session=0)
assert v.is_valid() == (True, []) # a warning in 1.0.x, an error from 1.1
assert any("has a url but no content_hash" in w for w in v.get_validation_warnings())
v.add_dialog(_recording(url="https://www.youtube.com/watch?v=x"), session=0)
v.add_attachment("doc", url="https://example.com/d.pdf", party=0, session=0)
v.add_analysis(type="summary", vendor="v", url="https://example.com/s.json",
sessions=0, body=None)
assert v.is_valid() == (True, [])
assert not any("content_hash" in w for w in v.get_validation_warnings())

def test_redacted_and_amended_from_still_need_content_hash(self):
v = _base()
v.vcon_dict["amended_from"] = {"url": "https://example.com/v.json"}
assert "amended_from with url must include content_hash." in v.is_valid()[1]

def test_well_formed_hash_passes(self):
v = _base()
Expand All @@ -52,7 +62,7 @@ def test_hash_array_and_unknown_algorithm(self):

def test_attachment_and_analysis_are_checked(self):
v = _base()
v.add_attachment("doc", url="https://example.com/d.pdf", party=0, session=0)
v.vcon_dict["attachments"].append({"purpose": "doc", "start": T, "party": 0, "session": 0})
v.add_analysis(type="summary", vendor="v", url="https://example.com/s.json",
content_hash="sha512-x", sessions=0, body=None)
errors = v.is_valid()[1]
Expand Down
Loading