Answer stability round 1: 0 🔴, 1 🟡 (0 misread); an unedited save over a version a teammate moved refuses, and a test asserts the PUT rather than the token
This commit is contained in:
@@ -88,8 +88,13 @@ class ConfluencePage:
|
||||
seen = self.seen_of(over)
|
||||
if isinstance(seen, Failure):
|
||||
return seen
|
||||
# The markdown a read shows drops the localIds and spacing paragraphs Confluence holds, so writing the text a read found back would lose them: leave the page alone.
|
||||
# The markdown a read shows drops the localIds and spacing paragraphs Confluence holds, so writing the text a read found back would lose them: leave the page alone. No write means no 409, so the version is read instead: a save over a teammate's edit refuses whether or not the text changed.
|
||||
if over is not None and seen.digest == digest_of(text):
|
||||
current = self.fetched("")
|
||||
if isinstance(current, Failure):
|
||||
return current
|
||||
if current[0].version != seen.version:
|
||||
return self.saved_since(seen.version, f"Confluence holds version {current[0].version}")
|
||||
return Held(text, over)
|
||||
document = self.to_adf(text)
|
||||
if isinstance(document, Failure):
|
||||
@@ -100,11 +105,15 @@ class ConfluencePage:
|
||||
body = {"id": self.page.page_id, "status": "current", "title": seen.title, "body": {"representation": "atlas_doc_format", "value": json.dumps(document)}, "version": {"number": seen.version + 1}}
|
||||
answer = self.http("PUT", self.url, authorization, body)
|
||||
if isinstance(answer, ErrorAnswer) and answer.status == CONFLICT:
|
||||
return Failure(f"someone saved {self.label} since the loop read version {seen.version} of it, so the loop didn't write it: never overwrite their edit, but ask the human what to do ({answer.reason})")
|
||||
return self.saved_since(seen.version, answer.reason)
|
||||
if isinstance(answer, Failure):
|
||||
return Failure(f"cannot write {self.label}: {answer.reason}")
|
||||
return Held(text, Seen(seen.version + 1, seen.title, digest_of(text)).token)
|
||||
|
||||
def saved_since(self, version: int, evidence: str) -> Failure:
|
||||
"""The refusal of a write over version, which a teammate's save replaced, as evidence shows."""
|
||||
return Failure(f"someone saved {self.label} since the loop read version {version} of it, so the loop didn't write it: never overwrite their edit, but ask the human what to do ({evidence})")
|
||||
|
||||
def fetched(self, query: str) -> tuple[Seen, object] | Failure:
|
||||
"""The page's version and title, and the value of its body in atlas_doc_format where query asks for it; None where it doesn't."""
|
||||
authorization = basic_auth(self.env_file)
|
||||
|
||||
Reference in New Issue
Block a user