Skip to content

fix: return a writable copy from get_rule_config - #59

Merged
ggmarshall merged 1 commit into
mainfrom
fix-rule-config-copy
Sep 25, 2026
Merged

ggmarshall merged 1 commit into
mainfrom
fix-rule-config-copy

Conversation

@ggmarshall

@ggmarshall ggmarshall commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor
  • I have reviewed all the code in this pull request and deem it of the standard expected for this project.

Since dbetto 1.3.5 (gipert/dbetto#48), TextDB.on() returns objects that share their contents with the database cache, flagged read-only. So a script can't edit its own rule config: config[...] = ... raises TypeError. And the dict/list methods dbetto doesn't guard (pop, setdefault, append, …) silently change the shared copy. build_log's setdefault path is one latent example.

get_rule_config now returns a copy.deepcopy of the rule config. It's small and resolved once per script, so each script owns its config regardless of dbetto's read-only rules.

Validation. The extended test_get_rule_config edits the returned config and checks that a second call is unaffected. It fails on main (TypeError: this AttrsDict is read-only) and passes here. pytest -n 5 gives 83 passed with dbetto 1.4.0 and with the read-only fix in gipert/dbetto. legend-dataflow pytest -n 5 gives 128 passed with this branch. pre-commit run -a passes.

🤖 Generated with Claude Code

TextDB.on() results are shared with the database cache and read-only since
dbetto 1.3.5, so scripts could not edit their rule config (or, through
unguarded methods, silently changed the shared copy). Deep-copy the small
rule config so every script owns it.

Assisted-by: Generative AI
Copilot AI lite review requested due to automatic review settings September 25, 2026 23:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ggmarshall
ggmarshall merged commit 2bee189 into main Sep 25, 2026
10 checks passed
@ggmarshall
ggmarshall deleted the fix-rule-config-copy branch September 25, 2026 23:54
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.

2 participants