Skip to content

Keep rejected ManyToMany additions from changing keys - #601

Closed
Gambit-Checkmate wants to merge 1 commit into
mahmoud:masterfrom
Gambit-Checkmate:fix/manytomany-rejected-add
Closed

Gambit-Checkmate wants to merge 1 commit into
mahmoud:masterfrom
Gambit-Checkmate:fix/manytomany-rejected-add

Conversation

@Gambit-Checkmate

@Gambit-Checkmate Gambit-Checkmate commented Oct 23, 2026 •

Copy link
Copy Markdown

The change

Closes #600.

Validate the value's hashability before creating its forward key in ManyToMany.add. A rejected list/dict/set value currently leaves an empty key in the relation, changing its length and iteration despite raising TypeError. Adding through the inverse relation has the same problem.

The regression tests check unchanged forward/inverse edges and key sets for six invalid additions, plus successful and repeated additions in both directions. All six invalid cases fail before the fix; both positive controls pass.

Validation on Windows / CPython 3.13.13:

  • Full tests and doctests: 686 passed, 12 subtests passed.
  • Ruff check --select E9,F on the changed Python files: passed.
  • compileall for changed Python files and git diff --check: passed.
  • Source distribution and wheel build: passed.

Other Python versions and platforms await upstream CI. This does not change copying/update behavior (#526) or replacement behavior (previously proposed in #528).

The backstory

This is another contribution from the same automated contribution effort as #567. Source inspection found that failed add calls create a key before rejecting the value, and a short example reproduced the state change. This was discovered through code inspection, not through personal production use; the example is a reproducer rather than a claimed incident.

AI assistance

  • Harness/tooling: OpenAI Codex, Git, GitHub CLI/API, Python, pytest and Ruff. Codex performed investigation, implementation, testing and submission.
  • Model(s): GPT-6 family; the exact deployment identifier is not exposed in this session.
  • Original prompt(s), relevant verbatim excerpts from the daily automation (the mailbox workflow and local memory path are omitted):

每天早上 8 点在本会话实际提交两个高质量的开源贡献 PR,把创建并获得 GitHub PR 链接作为每日完成目标。首批候选不合适时必须继续扩大仓库与问题搜索范围,不因候选重复、单个问题困难或尚未发现合适 issue 就结束;没有合适公开 issue 时可以检查代码、复现真实缺陷,确认无重复后报告问题并提交独立修复。

只有改动真实、有依据、验证充分且账号有权限时才推送分支并创建 PR;绝不降低 star 门槛,不提交空改动、无关改动、未经验证或重复 PR,尊重上游 AI 贡献和认领规则。

Hosted CI: Actions run39876090658 is action_required for external-contribution approval; no hosted tests have executed for this head yet.

@mahmoud

mahmoud commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Folded into #609 (see the PR description for credit). Thanks for the report and the repro.

@mahmoud mahmoud closed this Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rejected ManyToMany.add calls leave empty relationship keys

2 participants