Skip to content

Raise the errors that were logged, merge MissingEntityException into NonExistentEntityError - #1226

Merged
LeMyst merged 1 commit into
masterfrom
raise-errors
Nov 15, 2026
Merged

LeMyst merged 1 commit into
masterfrom
raise-errors

Conversation

@LeMyst

@LeMyst LeMyst commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Fixes #453, with your answers: the four logged cases change, and MissingEntityException merges into NonExistentEntityError. The first item of the issue (the assert checks) was done in #1213.

Logged instead of raised

Where Before Now Breaking
References.add() with a claim that has qualifiers or references warning in the log, qualifiers and references dropped ValueError, nothing added yes
Login / Clientlogin with a keyword argument other than headers, proxies, timeout, verify warning in the log, argument ignored TypeError, before any request yes
Claim.ref_present(), used by MERGE_REFS_OR_APPEND, for a new claim with 0 or 2+ references UserWarning no warning, same result no
write() when the API call fails exception logged with its traceback, then raised only raised no

MissingEntityException merged into NonExistentEntityError

A deleted entity, a revision that doesn't exist and a MediaInfo title that isn't found now raise NonExistentEntityError, like an unknown id already did. The code tells them apart:

Case code
unknown id (API error, unchanged) no-such-entity
page missing (API error, unchanged), MediaInfo title not found missingtitle
entity missing, e.g. deleted (get(), delete(), generate_entity_instances()) missing
revision missing (get(revision=)) nosuchrevid

response is set where there's an API response.

Deprecation: MissingEntityException is now another name of NonExistentEntityError, served by a module __getattr__ with a DeprecationWarning, like wbi_helpers.BColors. It goes in 1.0.

  • except MissingEntityException keeps working, and also catches the unknown ids.
  • except MWApiError now catches the missing entities too, since NonExistentEntityError is an MWApiError. That's listed in upgrading.md.

After the merge, I'll add MissingEntityException to the 1.0 removal table of #1192.

Docs

  • upgrading.md: five entries in "Breaking changes in v0.15", and one in "Deprecated in v0.15, removed in 1.0".
  • API reference: MissingEntityException is no longer listed. The NonExistentEntityError docstring lists the codes.
  • Login docstrings: they list the supported keyword arguments.

Tests

  • Updated: the tests that pinned the old behavior.
    • References.add() is parametrized over qualifiers, references and both.
    • The login test checks that no request is made.
    • The MERGE_REFS_OR_APPEND test turns warnings into errors.
    • The write() error test checks that nothing is logged.
  • Moved: the MissingEntityException tests now expect NonExistentEntityError and check its code. This includes the integration tests.
  • New: tests for the deprecated alias and for an unknown attribute of wbi_exceptions.
  • Results:

🤖 Generated with Claude Code

#453, as decided on 2026-11-15:
- References.add() raises a ValueError for a claim with qualifiers or
  references, which it used to drop with a warning in the log.
- Login and Clientlogin raise a TypeError for an unsupported keyword
  argument, which they used to ignore with a warning in the log.
- Claim.ref_present() no longer warns for a normal case of
  MERGE_REFS_OR_APPEND.
- write() no longer logs the exception it raises.
- A missing entity, revision or MediaInfo title raises
  NonExistentEntityError (codes missing, nosuchrevid, missingtitle).
  MissingEntityException is a deprecated name of it, removed in 1.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LeMyst LeMyst added this to the v1.0 milestone Nov 15, 2026
@LeMyst LeMyst added the breaking change Not backward compatible, needs a release note label Nov 15, 2026
@LeMyst
LeMyst merged commit 488afcd into master Nov 15, 2026
21 checks passed
@LeMyst
LeMyst deleted the raise-errors branch November 15, 2026 20:46
This was referenced Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Not backward compatible, needs a release note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Raise clear exceptions instead of logging

1 participant