Skip to content

store_entity reports success for a page it never created #175

Description

@LukasGold

Problem

OSW.store_entity can return normally and list a page in created_pages when
that page does not exist on the wiki afterwards. The caller has no way to tell
a write that applied from one that did not.

Where

created_pages[page.title] = page at
https://github.com/OpenSemanticLab/osw-python/blob/9aa6322/src/osw/core.py#L1874
runs unconditionally:

if param.offline is False and not kept_existing:
    page.edit(param.edit_comment, bot_edit=param.bot_edit)
if not param.offline and page.changed:
    ...  # print "Entity stored at ..."
created_pages[page.title] = page

The assignment is at the same indentation as the if above it, so it runs for
every page regardless of what the edit did.

The comment at
https://github.com/OpenSemanticLab/osw-python/blob/9aa6322/src/osw/core.py#L1925
claims the opposite:

# swallowed (store_entity_ only records created_pages on success).

"Success" there means only "no exception was raised". It does not mean the page
exists.

Reproduction

Measured three times on osl.dev.afin-data.de at commit 9aa6322:

  1. Build a Person with surname set and no label.
  2. osw.store_entity(...) returns normally and prints Entity stored at '<url>'.
    page.changed is True.
  3. Clear the page cache, then get_page the same title: exists is False.
  4. Special:AllPages does not list the page.

The same Person written with a label produces a page that exists. So the
failure depends on the payload, not on connectivity or permissions.

What the cause is not

The server-side reason is not identified. Ruled out by measurement:

  • Not the osw-python page cache. The read was done with the cache cleared.
  • Not replication lag. A re-read several minutes later still reported exists == False.
  • Not a swallowed exception. store_entity_ raised nothing.

A form or template driven creation step on the Person category is the
remaining suspicion, but I did not confirm it.

Why it is still a library defect

The library-side problem is independent of the server-side cause. Whatever makes
the write fail, store_entity should not report that page as created. Checking
page.changed does not help here, because page.changed was True in the
failing case as well.

Suggested fix

Read the page back after the edit and record it in created_pages only if it
exists, or return the absent titles to the caller as failures. Also correct the
comment at src/osw/core.py:1925.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions