From b6a576187a1f965fffc68096951207b040531638 Mon Sep 17 00:00:00 2001 From: Lilleman Date: Tue, 24 Nov 2026 07:35:01 +0100 Subject: [PATCH 1/7] File item 533, a patch release 0.15.1 for Jira's refused score edits --- CHANGELOG.md | 2 +- todo.md | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e09e0ce3..664d0a93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ - `task-bench --tasks data-sources` benches adding a data source: Haiku gets a made-up register that the task's seeded `generate-register` writes, and acceptance tests check the importer, the data and whatever else the spec asks. - `task-bench --tasks features` has Haiku build features instead of fixing planted bugs: each folder in the folder the project's config names as the new optional `bench-tasks` holds a `spec.md`, a `reference.patch` and acceptance tests Haiku never sees. A feature counts only where those tests fail before it is built and pass with the reference patch, at the base and at the head; the report names each feature passed over and why. - A bench started with `task-bench --record-figures` appends its figures over every bug to the comprehension history once it finishes, and a scoring run in `larv-review` starts the project's bench that way where its README documents a `task-bench` command. The figures are a report beside the panel's scores: none blocks a merge. -- `task-bench`'s table prints the mean of the bugs' own head/base changes as its All change, in place of the change of the two All rows' medians, which swung up to three times as far in tokens. The All rows per side stay, so the change row is no longer their difference, and a change from before 0.15.1 can't be compared with one from after it. +- `task-bench`'s table prints the mean of the bugs' own head/base changes as its All change, in place of the change of the two All rows' medians, which swung up to three times as far in tokens. The All rows per side stay, so the change row is no longer their difference, and a change from before 0.16.0 can't be compared with one from after it. - `task-bench` now stops with a Failure on a run whose final result says `terminal_reason: "api_error"`, even where it holds no `api_error_status`, so a token the API refuses no longer lets the bench run on for hours with empty runs. - `task-bench`'s `--help` now says how far a bench of a commit against itself swings, in 19 cases of 20, with the default 5 bugs and 5 runs, and that a Gremlins run on a large project needs 16 GB of memory. - When `task-bench` can't copy, read or write a file in the middle of a bench, it now names that file and still prints the table of the runs that finished, where 0.15.0 lost them all behind `could not write under `. diff --git a/todo.md b/todo.md index 4bca87e6..ae4230e4 100644 --- a/todo.md +++ b/todo.md @@ -6,16 +6,13 @@ `Bar = 0.1` -`Next ID = 533` - -## Renamed - -- 0.15.1 renamed to 0.16.0 +`Next ID = 534` ## Items | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| +| 533 | 0.15.1 | | defect | **Set an issue's scores in Jira through its issue-property endpoint, so do-epic and `todo-item edit` save them where Jira refuses an edit that holds only properties.** | 2 | 2 | 2 | 4 | 3 | 1.6 by 3, 1.1 by 2 | 1.7 | | 531 | 0.16.0 | | | **Bench the shipped features of a branch that landed by fast-forward: take as the feature the commits from the one after the item finished before it, up to the commit that took its item out of the plan.** | 2 | 2 | 1 | 3 | 3 | 1.1 by 3 | 1.1 | | 524 | 0.16.0 | | owner | **Write fejkdata's first six bench features, each a spec, acceptance tests in Go and a reference patch that builds it, in the `bench-tasks` folder its config names.** | 3 | 2 | 1 | 4 | 6 | 1.1 by 3 | 0.5 | | 532 | 0.16.0 | | | **Leave out of a `task-bench` fix a change Haiku makes to a Rust test that stands in the file of the code it tests.** | 2 | 2 | 1 | 3 | 3 | 1.1 by 1 | 0.4 | @@ -112,6 +109,20 @@ ## Details +### 533. Set an issue's scores in Jira through its issue-property endpoint, so do-epic and `todo-item edit` save them where Jira refuses an edit that holds only properties. + +Jira Cloud's edit request, `PUT /rest/api/3/issue/{key}`, refuses a body that holds `properties` without `fields` or `update`: it answers 400 "one of 'fields' or 'update' required". do-epic's scoring sends exactly that body, after it has posted the comment that tells the team the scores. So on a team's epic every scored issue got the comment but no scores, and each later run would score and comment on it again. `todo-item edit` sends the same body where it changes only the scores of an issue, as it does on an issue a person filed. The test fakes accepted the body, so no test saw it. + +Fix: one function in `bin/atlassian/jira.py` sends an issue edit. Where the edit sets only issue properties, it sets each through `PUT /rest/api/3/issue/{key}/properties/{propertyKey}`, whose body is the property's value. Both callers use it, and both fakes refuse an edit that holds neither `fields` nor `update`, as Jira does. + +Touches: +- `bin/atlassian/jira.py`: `edited` +- `bin/atlassian/test_jira.py`: `Edited` +- `bin/do_epic/backend/jira.py`: `JiraEpic.set_scores` (small) +- `bin/do_epic/backend/test_jira.py`: `FakeJira` (small) +- `bin/plan_store/jira_epic.py`: `JiraPlan.edit` (small) +- `bin/plan_store/test_jira_epic.py`: `Editing` (small) + ### 531. Bench the shipped features of a branch that landed by fast-forward: take as the feature the commits from the one after the item finished before it, up to the commit that took its item out of the plan. Today `task-bench --tasks shipped-features` passes such a feature over. A fast-forwarded branch's commits keep a commit time each, so `branch_chunks` cuts each commit into a chunk of its own, and the chunk that took the item out of the plan holds only the feature's last commit. This project landed 114 of its 260 shipped features that way, and none of those can be benched. A squash-merged feature whose one commit was authored and committed at the same time would be passed over too; whether a forge writes such commits is not checked. -- 2.52.0 From b3bb2dd3f5633b0732ac0ac7e2d69badcaeab1c6 Mon Sep 17 00:00:00 2001 From: Lilleman Date: Tue, 24 Nov 2026 07:38:55 +0100 Subject: [PATCH 2/7] Set an issue's scores through its property endpoint where an edit holds neither fields nor update --- bin/atlassian/jira.py | 12 ++++++++++++ bin/atlassian/test_jira.py | 32 ++++++++++++++++++++++++++++++++ bin/do_epic/backend/jira.py | 4 ++-- bin/do_epic/backend/test_jira.py | 13 +++++++------ bin/plan_store/jira_epic.py | 6 +++--- bin/plan_store/test_jira_epic.py | 14 ++++++++------ 6 files changed, 64 insertions(+), 17 deletions(-) diff --git a/bin/atlassian/jira.py b/bin/atlassian/jira.py index 5d940053..eabc59ed 100644 --- a/bin/atlassian/jira.py +++ b/bin/atlassian/jira.py @@ -154,6 +154,18 @@ def project_of(key: str) -> str: return key.rpartition("-")[0] +def edit_issue(site: str, key: str, body: dict[str, typing.Any], authorization: str, http: Http) -> None | Failure: + """Sends an edit of the issue named key: its fields, its updates and its issue properties in one request, or the Failure Jira answered. Jira refuses an edit that holds neither fields nor update, so such an edit sets each property through the property's own endpoint, one request each, and stops at the first that fails.""" + if "fields" in body or "update" in body: + answer = http("PUT", f"{site}/rest/api/3/issue/{key}", authorization, body) + return answer if isinstance(answer, Failure) else None + for entry in body.get("properties", []): + answer = http("PUT", f"{site}/rest/api/3/issue/{key}/properties/{entry['key']}", authorization, entry["value"]) + if isinstance(answer, Failure): + return answer + return None + + def rank_refusal(site: str, key: str, before: str, authorization: str, http: Http) -> str | None: """Ranks the issue named key just before the issue named before; why Jira refused, or None where it didn't. Jira answers a rank it made with no body, and one it refused with an error, or with an entry per issue that holds the errors.""" answer = http("PUT", f"{site}/rest/agile/1.0/issue/rank", authorization, {"issues": [key], "rankBeforeIssue": before}) diff --git a/bin/atlassian/test_jira.py b/bin/atlassian/test_jira.py index 0e086c59..5db09715 100644 --- a/bin/atlassian/test_jira.py +++ b/bin/atlassian/test_jira.py @@ -109,3 +109,35 @@ class TheRefusalOfAnIssueType(unittest.TestCase): if __name__ == "__main__": unittest.main() + + +class AnIssueEdit(unittest.TestCase): + def setUp(self) -> None: + self.calls: list[tuple[str, str, object]] = [] + self.answer: object = None + + def http(self, method: str, url: str, authorization: str, body: object) -> object: + self.calls.append((method, url, body)) + return self.answer + + def edit(self, body: dict[str, object]) -> None | Failure: + return jira.edit_issue("https://acme.atlassian.net", "ABC-1", body, "Basic x", self.http) + + def test_sends_fields_update_and_properties_in_one_request(self): + body = {"fields": {"summary": "Count."}, "update": {"labels": [{"add": "security"}]}, "properties": [{"key": "plan", "value": {"L": 2}}]} + self.assertIsNone(self.edit(body)) + self.assertEqual(self.calls, [("PUT", "https://acme.atlassian.net/rest/api/3/issue/ABC-1", body)]) + + def test_sets_each_property_of_an_edit_without_fields_or_update_through_the_property_endpoint(self): + # Jira's edit refuses such a body: "one of 'fields' or 'update' required". + self.assertIsNone(self.edit({"properties": [{"key": "plan", "value": {"L": 2}}, {"key": "seen", "value": True}]})) + self.assertEqual(self.calls, [ + ("PUT", "https://acme.atlassian.net/rest/api/3/issue/ABC-1/properties/plan", {"L": 2}), + ("PUT", "https://acme.atlassian.net/rest/api/3/issue/ABC-1/properties/seen", True), + ]) + + def test_a_request_jira_refuses_is_its_failure_and_sets_no_later_property(self): + self.answer = Failure("Jira answered 503") + self.assertEqual(self.edit({"fields": {"summary": "Count."}}), Failure("Jira answered 503")) + self.assertEqual(self.edit({"properties": [{"key": "plan", "value": {}}, {"key": "seen", "value": True}]}), Failure("Jira answered 503")) + self.assertEqual(len(self.calls), 2) diff --git a/bin/do_epic/backend/jira.py b/bin/do_epic/backend/jira.py index 269580ce..2a664a84 100644 --- a/bin/do_epic/backend/jira.py +++ b/bin/do_epic/backend/jira.py @@ -7,7 +7,7 @@ from adf_codec.convert import adfs_to_markdown, markdown_to_adf, Refused from atlassian.client import basic_auth, Http, jira_json, ToAdf, ToMarkdown from plan_store.jira_epic import BLOCKS, FILED_BY, scores as held_scores, PROPERTY from project_config.settings import DEFAULT_ISSUE_TYPE, Epic, Finish, JIRA_FINDING_TYPE, JIRA_FINISH_STATUS, JIRA_FINISH_TRANSITION, JIRA_REVIEW_TYPE -from atlassian.jira import DONE, entry_of, finishing_transition, ISSUE_KEY, issue_type_refusal, issue_types_of, MAX_PAGES, move_refusal, PERHAPS_FILED, PERHAPS_MOVED, project_of, rank_refusal, searched, SHAPE, status_category, unshaped +from atlassian.jira import DONE, edit_issue, entry_of, finishing_transition, ISSUE_KEY, issue_type_refusal, issue_types_of, MAX_PAGES, move_refusal, PERHAPS_FILED, PERHAPS_MOVED, project_of, rank_refusal, searched, SHAPE, status_category, unshaped from do_epic.backend.protocol import EpicIssue, no_blocker, no_child, no_parent, no_scores, no_words, unfit, unfit_label from failure import Failure from do_epic.backend.jira_status import moved_by, moved_to @@ -195,7 +195,7 @@ class JiraEpic: posted = self.http("POST", f"{self.epic.site}/rest/api/3/issue/{key}/comment", authorization, {"body": body}) if isinstance(posted, Failure): return Failure(f"cannot comment on {key} to tell its team the scores: {posted.reason}") - put = self.http("PUT", f"{self.epic.site}/rest/api/3/issue/{key}", authorization, {"properties": [{"key": PROPERTY, "value": held | scores | {MOVES: moves}}]}) + put = edit_issue(self.epic.site, key, {"properties": [{"key": PROPERTY, "value": held | scores | {MOVES: moves}}]}, authorization, self.http) return Failure(f"the comment on {key} tells its team the scores, but they could not be set, so the next run scores it again: {put.reason}") if isinstance(put, Failure) else None def start_issue(self, key: str) -> str | None | Failure: diff --git a/bin/do_epic/backend/test_jira.py b/bin/do_epic/backend/test_jira.py index 5da2d0ea..68840910 100644 --- a/bin/do_epic/backend/test_jira.py +++ b/bin/do_epic/backend/test_jira.py @@ -119,12 +119,13 @@ class FakeJira: assert isinstance(body, dict) self.comments.setdefault(str(held["key"]), []).append(body["body"]) return {"id": "1"} + if method == "PUT" and (held := next((issue for issue in self.issues if url.startswith(f"{ISSUES}/{issue['key']}/properties/")), None)): + held.setdefault("properties", {})[url.rpartition("/")[2]] = body # type: ignore[attr-defined] + return None if method == "PUT" and (held := next((issue for issue in self.issues if url == f"{ISSUES}/{issue['key']}"), None)): assert isinstance(body, dict) - if "properties" in body: - [entry] = body["properties"] - held.setdefault("properties", {})[entry["key"]] = entry["value"] # type: ignore[attr-defined] - return None + if "fields" not in body and "update" not in body: + return Failure("Jira answered 400: one of 'fields' or 'update' required") added = [change["add"] for change in body["update"]["labels"]] held["fields"]["labels"] = sorted({*held["fields"]["labels"], *added}) # type: ignore[index] return None @@ -286,9 +287,9 @@ class Jira(Case): self.jira.answers[("POST", f"{ISSUES}/{key}/comment")] = Failure("Jira answered 503") self.assertEqual(store.set_scores(key, scores, "", "Scored."), Failure(f"cannot comment on {key} to tell its team the scores: Jira answered 503")) del self.jira.answers[("POST", f"{ISSUES}/{key}/comment")] - self.jira.answers[("PUT", f"{ISSUES}/{key}")] = Failure("Jira answered 503") + self.jira.answers[("PUT", f"{ISSUES}/{key}/properties/plan-item")] = Failure("Jira answered 503") self.assertEqual(store.set_scores(key, scores, "", "Scored."), Failure(f"the comment on {key} tells its team the scores, but they could not be set, so the next run scores it again: Jira answered 503")) - del self.jira.answers[("PUT", f"{ISSUES}/{key}")] + del self.jira.answers[("PUT", f"{ISSUES}/{key}/properties/plan-item")] # No scores were set while the comment failed, so the issue is still scored once Jira answers. self.assertIsNone(store.set_scores(key, scores, "", "Scored.")) diff --git a/bin/plan_store/jira_epic.py b/bin/plan_store/jira_epic.py index a0b984e2..5e0c8082 100644 --- a/bin/plan_store/jira_epic.py +++ b/bin/plan_store/jira_epic.py @@ -13,7 +13,7 @@ from plan.todo_table import BLOCKED_BY, Item, item_fields, ItemFields, MOVES, SH from plan_store.markdown_edits import bold_cell, plain, unfit_text from plan_store.plans import cells, no_item, Plan, Written from project_config.settings import DEFAULT_ISSUE_TYPE, Epic, Finish, JIRA_FINDING_TYPE, JIRA_FINISH_STATUS, JIRA_FINISH_TRANSITION -from atlassian.jira import entry_of, finishing_transition, ISSUE_KEY, issue_type_refusal, Link, MAX_PAGES, move_refusal, PERHAPS_FILED, PERHAPS_MOVED, project_of, rank_refusal, searched, unshaped +from atlassian.jira import edit_issue, entry_of, finishing_transition, ISSUE_KEY, issue_type_refusal, Link, MAX_PAGES, move_refusal, PERHAPS_FILED, PERHAPS_MOVED, project_of, rank_refusal, searched, unshaped from failure import Failure from plan.release import parsed, Release, tagged from plan import ranking @@ -198,7 +198,7 @@ class JiraPlan: return isinstance(texts, list) and texts[0].strip() == detail.strip() def edit(self, id_: int, fields: dict[str, str], detail: str | None, comment: str | None = None) -> Written | Failure: - """Sets the fields and the detail in one request, so Jira takes all of those or none, then changes the issue's links one request at a time, and then posts comment on the issue. `revision_of` says what an edit may set. + """Sets the fields, the detail and the scores in one request, so Jira takes all of those or none, or sets the scores alone as `edit_issue` says, then changes the issue's links one request at a time, and then posts comment on the issue. `revision_of` says what an edit may set. A link change or a comment Jira refuses leaves the edit made, so the write counts as landed, and a note says what to do by hand.""" authorization = basic_auth(self.env_file) @@ -237,7 +237,7 @@ class JiraPlan: return version body = body | {"fields": body.get("fields", {}) | {"fixVersions": [{"name": version}]}} url = f"{self.epic.site}/rest/api/3/issue/{key}" - edited = self.http("PUT", url, authorization, body) if body else None + edited = edit_issue(self.epic.site, key, body, authorization, self.http) if body else None if isinstance(edited, Failure): return Failure(f"cannot edit {key}: {edited.reason}; {PERHAPS_EDITED.format(key=key)}") notes = self.relinked(issue, revision.blockers, open_keys, authorization) diff --git a/bin/plan_store/test_jira_epic.py b/bin/plan_store/test_jira_epic.py index 1300921f..4611484e 100644 --- a/bin/plan_store/test_jira_epic.py +++ b/bin/plan_store/test_jira_epic.py @@ -540,7 +540,8 @@ class Editing(unittest.TestCase): def test_sends_only_what_the_edit_names(self): self.edit(34, {"Tagline": "Count every run."}) self.edit(34, {"E": "3"}) - self.assertEqual([body for _, _, body in self.writes()], [{"fields": {"summary": "Count every run."}}, {"properties": [{"key": "plan-item", "value": PROPERTY | {"E": 3}}]}]) + self.assertEqual([body for _, _, body in self.writes()], [{"fields": {"summary": "Count every run."}}, PROPERTY | {"E": 3}]) + self.assertEqual(self.writes()[1][1], f"{ISSUES}/ABC-34/properties/plan-item") def test_a_detail_unchanged_since_the_read_leaves_the_description_as_jira_holds_it(self): # Jira's own spacing paragraph and localIds, which a description converted back from markdown would lose. @@ -548,7 +549,7 @@ class Editing(unittest.TestCase): self.open = [issue("ABC-34", scores=PROPERTY, description=held)] self.assertEqual(self.edit(34, {"L": "2"}, "Why it counts.\n"), Written(34)) self.assertEqual(self.edit(34, {}, "Why it counts."), Written(34)) - self.assertEqual(self.writes(), [("PUT", f"{ISSUES}/ABC-34", {"properties": [{"key": "plan-item", "value": PROPERTY | {"L": 2}}]})]) + self.assertEqual(self.writes(), [("PUT", f"{ISSUES}/ABC-34/properties/plan-item", PROPERTY | {"L": 2})]) def test_an_edited_detail_replaces_the_description(self): self.open = [issue("ABC-34", scores=PROPERTY, description=adf("Why it counts."))] @@ -586,17 +587,18 @@ class Editing(unittest.TestCase): def test_scores_an_issue_a_person_filed_and_comments_why(self): self.assertEqual(self.edit(35, {"L": "2", "E": "2", "I": "3", "S": "3", "Moves": "1 by 4"}, None, COMMENT), Written(35)) self.assertEqual(self.writes(), [ - ("PUT", f"{ISSUES}/ABC-35", {"properties": [{"key": "plan-item", "value": {"L": 2, "E": 2, "I": 3, "S": 3, "Moves": "1 by 4", "Exempt": ""}}]}), + ("PUT", f"{ISSUES}/ABC-35/properties/plan-item", {"L": 2, "E": 2, "I": 3, "S": 3, "Moves": "1 by 4", "Exempt": ""}), ("POST", f"{ISSUES}/ABC-35/comment", {"body": adf(COMMENT)}), ]) def test_rescores_a_persons_issue_that_holds_scores_keeping_the_rest(self): self.edit(36, {"L": "2"}, None, COMMENT) - self.assertEqual(self.writes()[0][2], {"properties": [{"key": "plan-item", "value": {"L": 2, "E": 1, "I": 1, "S": 2, "Moves": "", "Exempt": ""}}]}) + self.assertEqual(self.writes()[0][1:], (f"{ISSUES}/ABC-36/properties/plan-item", {"L": 2, "E": 1, "I": 1, "S": 2, "Moves": "", "Exempt": ""})) def test_a_persons_issue_is_never_labelled(self): self.edit(36, {"Exempt": "security"}, None, COMMENT) - self.assertNotIn("update", self.writes()[0][2]) # type: ignore[operator] + # Labelling would take an edit of the issue itself; scores alone go to its property. + self.assertEqual([url for _, url, _ in self.writes()], [f"{ISSUES}/ABC-36/properties/plan-item", f"{ISSUES}/ABC-36/comment"]) def test_scoring_a_persons_issue_without_a_comment_fails_before_any_write(self): for comment in (None, "", " \n"): @@ -663,7 +665,7 @@ class Editing(unittest.TestCase): def test_changes_the_links_after_the_edit_and_before_the_comment(self): self.assertEqual(self.edit(34, {"L": "2", "Blocked by": "35"}, None, COMMENT), Written(34)) - self.assertEqual([(method, url) for method, url, _ in self.writes()], [("PUT", f"{ISSUES}/ABC-34"), ("POST", LINKS), ("POST", f"{ISSUES}/ABC-34/comment")]) + self.assertEqual([(method, url) for method, url, _ in self.writes()], [("PUT", f"{ISSUES}/ABC-34/properties/plan-item"), ("POST", LINKS), ("POST", f"{ISSUES}/ABC-34/comment")]) def test_a_failed_edit_makes_no_link(self): self.edited = Failure("HTTP 400") -- 2.52.0 From 0c10eeb986f3cc6b18c0899cf59152c7fb0844a4 Mon Sep 17 00:00:00 2001 From: Lilleman Date: Tue, 24 Nov 2026 07:52:37 +0100 Subject: [PATCH 3/7] Kill the mutants of edit_issue: an empty edit sends nothing, and an answer on success is no failure --- bin/atlassian/test_jira.py | 8 ++++++++ bin/plan_store/jira_epic.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bin/atlassian/test_jira.py b/bin/atlassian/test_jira.py index 5db09715..bdd4333b 100644 --- a/bin/atlassian/test_jira.py +++ b/bin/atlassian/test_jira.py @@ -136,6 +136,14 @@ class AnIssueEdit(unittest.TestCase): ("PUT", "https://acme.atlassian.net/rest/api/3/issue/ABC-1/properties/seen", True), ]) + def test_an_answer_jira_sends_on_success_is_no_failure(self): + self.answer = {"id": "10001"} + self.assertIsNone(self.edit({"fields": {"summary": "Count."}})) + + def test_an_edit_that_sets_nothing_sends_no_request(self): + self.assertIsNone(self.edit({})) + self.assertEqual(self.calls, []) + def test_a_request_jira_refuses_is_its_failure_and_sets_no_later_property(self): self.answer = Failure("Jira answered 503") self.assertEqual(self.edit({"fields": {"summary": "Count."}}), Failure("Jira answered 503")) diff --git a/bin/plan_store/jira_epic.py b/bin/plan_store/jira_epic.py index 5e0c8082..7528e13a 100644 --- a/bin/plan_store/jira_epic.py +++ b/bin/plan_store/jira_epic.py @@ -237,7 +237,7 @@ class JiraPlan: return version body = body | {"fields": body.get("fields", {}) | {"fixVersions": [{"name": version}]}} url = f"{self.epic.site}/rest/api/3/issue/{key}" - edited = edit_issue(self.epic.site, key, body, authorization, self.http) if body else None + edited = edit_issue(self.epic.site, key, body, authorization, self.http) if isinstance(edited, Failure): return Failure(f"cannot edit {key}: {edited.reason}; {PERHAPS_EDITED.format(key=key)}") notes = self.relinked(issue, revision.blockers, open_keys, authorization) -- 2.52.0 From e96b8a8182af47076c8f39b8a2c9cfe8539bcf19 Mon Sep 17 00:00:00 2001 From: Lilleman Date: Tue, 24 Nov 2026 09:57:54 +0100 Subject: [PATCH 4/7] =?UTF-8?q?Answer=20security=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread);=20no=20findin?= =?UTF-8?q?gs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From fb55fc7a03b6385f3c8fe517ceeb22b59973b59f Mon Sep 17 00:00:00 2001 From: Lilleman Date: Tue, 24 Nov 2026 10:05:08 +0100 Subject: [PATCH 5/7] =?UTF-8?q?Answer=20stability=20round=201:=201=20?= =?UTF-8?q?=F0=9F=94=B4,=201=20=F0=9F=9F=A1=20(1=20misread);=20the=20plan?= =?UTF-8?q?=20store's=20fake=20refuses=20an=20edit=20with=20neither=20fiel?= =?UTF-8?q?ds=20nor=20update,=20and=200.15.1=20is=20cut=20off=20v0.15.0,?= =?UTF-8?q?=20never=20from=20main?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/plan_store/test_jira_epic.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/plan_store/test_jira_epic.py b/bin/plan_store/test_jira_epic.py index 4611484e..0674eda0 100644 --- a/bin/plan_store/test_jira_epic.py +++ b/bin/plan_store/test_jira_epic.py @@ -509,9 +509,11 @@ class Editing(unittest.TestCase): self.unlinked: object = None def http(self, method: str, url: str, authorization: str, body: object) -> object: - """Stands in for Jira: answers the epic, self.versions for the project's Fix Versions, self.open to the search, self.edited to an edit, self.commented to a new comment, self.linked to a new link and self.unlinked to a deleted one.""" + """Stands in for Jira: answers the epic, self.versions for the project's Fix Versions, self.open to the search, self.edited to an edit, self.commented to a new comment, self.linked to a new link and self.unlinked to a deleted one. Like Jira, it refuses an edit of an issue that holds neither fields nor update.""" self.calls.append((method, url, body)) assert authorization == AUTHORIZATION + if method == "PUT" and "/properties/" not in url and isinstance(body, dict) and "fields" not in body and "update" not in body: + return Failure("Jira answered 400: one of 'fields' or 'update' required") if method == "PUT": return self.edited if method == "DELETE": -- 2.52.0 From 0cf70b06b1532d91a209627a77e01b381f123853 Mon Sep 17 00:00:00 2001 From: Lilleman Date: Tue, 24 Nov 2026 10:05:08 +0100 Subject: [PATCH 6/7] =?UTF-8?q?Answer=20prose=20round=201:=201=20?= =?UTF-8?q?=F0=9F=94=B4,=203=20=F0=9F=9F=A1=20(0=20misread);=20clearer=20d?= =?UTF-8?q?ocstrings,=20test=20names=20and=20item=20text,=20and=20AnIssueE?= =?UTF-8?q?dit=20above=20the=20main=20guard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/atlassian/jira.py | 2 +- bin/atlassian/test_jira.py | 14 +++++++------- bin/plan_store/jira_epic.py | 2 +- todo.md | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bin/atlassian/jira.py b/bin/atlassian/jira.py index eabc59ed..5359e6f2 100644 --- a/bin/atlassian/jira.py +++ b/bin/atlassian/jira.py @@ -155,7 +155,7 @@ def project_of(key: str) -> str: def edit_issue(site: str, key: str, body: dict[str, typing.Any], authorization: str, http: Http) -> None | Failure: - """Sends an edit of the issue named key: its fields, its updates and its issue properties in one request, or the Failure Jira answered. Jira refuses an edit that holds neither fields nor update, so such an edit sets each property through the property's own endpoint, one request each, and stops at the first that fails.""" + """Sends body, an edit of the issue named key, and returns None, or the Failure of the request that failed. An edit that holds fields or update goes in one request, with its properties. Jira refuses an edit that holds neither, so such an edit sets each property through the property's own endpoint, one request each, and stops at the first that fails.""" if "fields" in body or "update" in body: answer = http("PUT", f"{site}/rest/api/3/issue/{key}", authorization, body) return answer if isinstance(answer, Failure) else None diff --git a/bin/atlassian/test_jira.py b/bin/atlassian/test_jira.py index bdd4333b..13388b86 100644 --- a/bin/atlassian/test_jira.py +++ b/bin/atlassian/test_jira.py @@ -107,10 +107,6 @@ class TheRefusalOfAnIssueType(unittest.TestCase): self.assertEqual(self.refusal("Bug", wrong), "Jira answered ABC's issue types in a shape its REST API version 3 doesn't document") -if __name__ == "__main__": - unittest.main() - - class AnIssueEdit(unittest.TestCase): def setUp(self) -> None: self.calls: list[tuple[str, str, object]] = [] @@ -136,16 +132,20 @@ class AnIssueEdit(unittest.TestCase): ("PUT", "https://acme.atlassian.net/rest/api/3/issue/ABC-1/properties/seen", True), ]) - def test_an_answer_jira_sends_on_success_is_no_failure(self): + def test_an_answer_jira_sends_on_success_counts_as_success(self): self.answer = {"id": "10001"} self.assertIsNone(self.edit({"fields": {"summary": "Count."}})) - def test_an_edit_that_sets_nothing_sends_no_request(self): + def test_an_empty_edit_doesnt_send_a_request(self): self.assertIsNone(self.edit({})) self.assertEqual(self.calls, []) - def test_a_request_jira_refuses_is_its_failure_and_sets_no_later_property(self): + def test_a_request_jira_refuses_is_its_failure_and_stops_the_later_properties(self): self.answer = Failure("Jira answered 503") self.assertEqual(self.edit({"fields": {"summary": "Count."}}), Failure("Jira answered 503")) self.assertEqual(self.edit({"properties": [{"key": "plan", "value": {}}, {"key": "seen", "value": True}]}), Failure("Jira answered 503")) self.assertEqual(len(self.calls), 2) + + +if __name__ == "__main__": + unittest.main() diff --git a/bin/plan_store/jira_epic.py b/bin/plan_store/jira_epic.py index 7528e13a..4424e35c 100644 --- a/bin/plan_store/jira_epic.py +++ b/bin/plan_store/jira_epic.py @@ -198,7 +198,7 @@ class JiraPlan: return isinstance(texts, list) and texts[0].strip() == detail.strip() def edit(self, id_: int, fields: dict[str, str], detail: str | None, comment: str | None = None) -> Written | Failure: - """Sets the fields, the detail and the scores in one request, so Jira takes all of those or none, or sets the scores alone as `edit_issue` says, then changes the issue's links one request at a time, and then posts comment on the issue. `revision_of` says what an edit may set. + """Sets the fields, the detail and the scores in one request, so Jira takes all of those or none. Where the edit changes only the scores, `edit_issue` sets them through their property's endpoint. Then it changes the issue's links one request at a time, and then posts comment on the issue. `revision_of` says what an edit may set. A link change or a comment Jira refuses leaves the edit made, so the write counts as landed, and a note says what to do by hand.""" authorization = basic_auth(self.env_file) diff --git a/todo.md b/todo.md index ae4230e4..c8b7be0d 100644 --- a/todo.md +++ b/todo.md @@ -111,9 +111,9 @@ ### 533. Set an issue's scores in Jira through its issue-property endpoint, so do-epic and `todo-item edit` save them where Jira refuses an edit that holds only properties. -Jira Cloud's edit request, `PUT /rest/api/3/issue/{key}`, refuses a body that holds `properties` without `fields` or `update`: it answers 400 "one of 'fields' or 'update' required". do-epic's scoring sends exactly that body, after it has posted the comment that tells the team the scores. So on a team's epic every scored issue got the comment but no scores, and each later run would score and comment on it again. `todo-item edit` sends the same body where it changes only the scores of an issue, as it does on an issue a person filed. The test fakes accepted the body, so no test saw it. +Jira Cloud's edit request, `PUT /rest/api/3/issue/{key}`, refuses a body that holds `properties` without `fields` or `update`: it answers 400 "one of 'fields' or 'update' required". do-epic's scoring sends exactly that body, after it has posted the comment that tells the team the scores. So on a team's epic every scored issue got the comment but no scores, and each later run would score and comment on it again. `todo-item edit` sends the same body where it changes only an issue's scores, which is all it may change on an issue a person filed. The test fakes accepted that body, so no test caught the refusal. -Fix: one function in `bin/atlassian/jira.py` sends an issue edit. Where the edit sets only issue properties, it sets each through `PUT /rest/api/3/issue/{key}/properties/{propertyKey}`, whose body is the property's value. Both callers use it, and both fakes refuse an edit that holds neither `fields` nor `update`, as Jira does. +Fix: one function in `bin/atlassian/jira.py` sends an issue edit. Where the edit sets only issue properties, it sets each through `PUT /rest/api/3/issue/{key}/properties/{propertyKey}`, whose body is the property's value. Both callers use it, and the fakes in both callers' tests refuse an edit that holds neither `fields` nor `update`, as Jira does. Touches: - `bin/atlassian/jira.py`: `edited` -- 2.52.0 From 1aa2367a3198fc517e1ad3f6066ad530b71b58fe Mon Sep 17 00:00:00 2001 From: Lilleman Date: Tue, 24 Nov 2026 10:08:20 +0100 Subject: [PATCH 7/7] Finish item 533 in the plan --- CHANGELOG.md | 1 + todo.md | 15 --------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 664d0a93..fb2356df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- `do-epic` and `todo-item edit` save an issue's scores in a Jira epic again. Jira refuses an edit that holds only issue properties, so 0.15.0 posted the comment with the scores but lost the scores themselves, and scored the issue again on the next run; each score now goes through the issue property's own endpoint. - `task-bench` plants bugs in Rust files too, from the mutants cargo-mutants catches, and tells Haiku the panic message `cargo test` prints. - `task-bench --tasks shipped-features` benches rebuilding features the project shipped: it takes each one's change out of the code, tells Haiku the tagline of its plan item, and checks the build with the tests that change holds. `--shipped ` sets how many it takes, and a feature whose branch landed by fast-forward is passed over. - `task-bench` plants a Python mutant in a file whose lines end in CRLF, which it could not re-apply before, and a Go mutant there keeps applying. diff --git a/todo.md b/todo.md index c8b7be0d..7804377a 100644 --- a/todo.md +++ b/todo.md @@ -12,7 +12,6 @@ | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| -| 533 | 0.15.1 | | defect | **Set an issue's scores in Jira through its issue-property endpoint, so do-epic and `todo-item edit` save them where Jira refuses an edit that holds only properties.** | 2 | 2 | 2 | 4 | 3 | 1.6 by 3, 1.1 by 2 | 1.7 | | 531 | 0.16.0 | | | **Bench the shipped features of a branch that landed by fast-forward: take as the feature the commits from the one after the item finished before it, up to the commit that took its item out of the plan.** | 2 | 2 | 1 | 3 | 3 | 1.1 by 3 | 1.1 | | 524 | 0.16.0 | | owner | **Write fejkdata's first six bench features, each a spec, acceptance tests in Go and a reference patch that builds it, in the `bench-tasks` folder its config names.** | 3 | 2 | 1 | 4 | 6 | 1.1 by 3 | 0.5 | | 532 | 0.16.0 | | | **Leave out of a `task-bench` fix a change Haiku makes to a Rust test that stands in the file of the code it tests.** | 2 | 2 | 1 | 3 | 3 | 1.1 by 1 | 0.4 | @@ -109,20 +108,6 @@ ## Details -### 533. Set an issue's scores in Jira through its issue-property endpoint, so do-epic and `todo-item edit` save them where Jira refuses an edit that holds only properties. - -Jira Cloud's edit request, `PUT /rest/api/3/issue/{key}`, refuses a body that holds `properties` without `fields` or `update`: it answers 400 "one of 'fields' or 'update' required". do-epic's scoring sends exactly that body, after it has posted the comment that tells the team the scores. So on a team's epic every scored issue got the comment but no scores, and each later run would score and comment on it again. `todo-item edit` sends the same body where it changes only an issue's scores, which is all it may change on an issue a person filed. The test fakes accepted that body, so no test caught the refusal. - -Fix: one function in `bin/atlassian/jira.py` sends an issue edit. Where the edit sets only issue properties, it sets each through `PUT /rest/api/3/issue/{key}/properties/{propertyKey}`, whose body is the property's value. Both callers use it, and the fakes in both callers' tests refuse an edit that holds neither `fields` nor `update`, as Jira does. - -Touches: -- `bin/atlassian/jira.py`: `edited` -- `bin/atlassian/test_jira.py`: `Edited` -- `bin/do_epic/backend/jira.py`: `JiraEpic.set_scores` (small) -- `bin/do_epic/backend/test_jira.py`: `FakeJira` (small) -- `bin/plan_store/jira_epic.py`: `JiraPlan.edit` (small) -- `bin/plan_store/test_jira_epic.py`: `Editing` (small) - ### 531. Bench the shipped features of a branch that landed by fast-forward: take as the feature the commits from the one after the item finished before it, up to the commit that took its item out of the plan. Today `task-bench --tasks shipped-features` passes such a feature over. A fast-forwarded branch's commits keep a commit time each, so `branch_chunks` cuts each commit into a chunk of its own, and the chunk that took the item out of the plan holds only the feature's last commit. This project landed 114 of its 260 shipped features that way, and none of those can be benched. A squash-merged feature whose one commit was authored and committed at the same time would be passed over too; whether a forge writes such commits is not checked. -- 2.52.0