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:
- Build a
Person with surname set and no label.
osw.store_entity(...) returns normally and prints Entity stored at '<url>'.
page.changed is True.
- Clear the page cache, then
get_page the same title: exists is False.
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.
Problem
OSW.store_entitycan return normally and list a page increated_pageswhenthat 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] = pageathttps://github.com/OpenSemanticLab/osw-python/blob/9aa6322/src/osw/core.py#L1874
runs unconditionally:
The assignment is at the same indentation as the
ifabove it, so it runs forevery 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.deat commit 9aa6322:Personwithsurnameset and nolabel.osw.store_entity(...)returns normally and printsEntity stored at '<url>'.page.changedisTrue.get_pagethe same title:existsisFalse.Special:AllPagesdoes not list the page.The same
Personwritten with alabelproduces a page that exists. So thefailure 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:
exists == False.store_entity_raised nothing.A form or template driven creation step on the
Personcategory is theremaining 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_entityshould not report that page as created. Checkingpage.changeddoes not help here, becausepage.changedwasTruein thefailing case as well.
Suggested fix
Read the page back after the edit and record it in
created_pagesonly if itexists, or return the absent titles to the caller as failures. Also correct the
comment at
src/osw/core.py:1925.