Skip to content

Fix incorrect subscription name in Phase 9 of ZODAN add_node#417

Merged
mason-sharp merged 2 commits intomainfrom
fix/SPOC-503/sub-name
Apr 14, 2026
Merged

Fix incorrect subscription name in Phase 9 of ZODAN add_node#417
mason-sharp merged 2 commits intomainfrom
fix/SPOC-503/sub-name

Conversation

@mason-sharp
Copy link
Copy Markdown
Member

@mason-sharp mason-sharp commented Apr 13, 2026

create_sub_on_new_node_to_src_node generated sub_{subscriber}_{provider} instead of the expected sub_{provider}_{subscriber} convention, causing remove-node to fail when looking up subscriptions by their expected name.

Introduce spock.gen_sub_name(provider_node, subscriber_node) helper and replace all inline 'sub_' || concatenations to prevent future mismatches.

create_sub_on_new_node_to_src_node generated sub_{subscriber}_{provider}
instead of the expected sub_{provider}_{subscriber} convention, causing
remove-node to fail when looking up subscriptions by their expected name.

Introduce spock.gen_sub_name(provider_node, subscriber_node) helper and
replace all inline 'sub_' || concatenations to prevent future mismatches.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mason-sharp mason-sharp requested a review from ibrarahmad April 13, 2026 20:40
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 13, 2026

📝 Walkthrough

Walkthrough

Added an immutable helper function spock.gen_sub_name(provider_node text, subscriber_node text) RETURNS text and replaced hardcoded subscription-name concatenations with calls to that function across SQL procedures; updated a test to use the new subscription naming order.

Changes

Cohort / File(s) Summary
Subscription name helper
samples/Z0DAN/zodan.sql
Added spock.gen_sub_name(...) (IMMUTABLE) and replaced `'sub_'
Tests updated for naming order
tests/t/012_zodan_basics.pl
Adjusted test calls to use the swapped subscription identifier (sub_n2_n1) when disabling/enabling subscriptions before Z0DAN node addition.

Poem

🐰 I hopped through concat vines, all knotted and wide,
A tidy little function I planted inside.
Now subs wear sub_provider_subscriber with pride,
No more string-stitching on the replication side.
Hooray for neat names—I've saved you some stride!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly reflects the main change: fixing an incorrect subscription name generation in Phase 9 of ZODAN add_node, which is the core issue addressed in the changeset.
Description check ✅ Passed The description clearly explains the bug (incorrect subscription naming pattern), its impact (remove-node failure), and the solution (introducing gen_sub_name helper), which aligns with the actual changes made.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/SPOC-503/sub-name

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codacy-production
Copy link
Copy Markdown

codacy-production bot commented Apr 13, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/tap/t/012_zodan_basics.pl (1)

54-74: Consider using spock.gen_sub_name in these test calls to avoid future drift.

Hardcoding the name in both places can regress again if naming rules evolve.

♻️ Suggested update
-psql_or_bail(1, "SELECT spock.sub_disable('sub_n2_n1')");
+psql_or_bail(1, "SELECT spock.sub_disable(spock.gen_sub_name('n2', 'n1'))");

...

-psql_or_bail(1, "SELECT spock.sub_enable('sub_n2_n1')");
+psql_or_bail(1, "SELECT spock.sub_enable(spock.gen_sub_name('n2', 'n1'))");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/tap/t/012_zodan_basics.pl` around lines 54 - 74, Replace the hardcoded
subscription name 'sub_n2_n1' with a generated name using spock.gen_sub_name to
prevent drift: update the psql_or_bail calls that invoke
spock.sub_disable('sub_n2_n1') and spock.sub_enable('sub_n2_n1') to compute the
subscription name via spock.gen_sub_name(...) (matching the same parameters used
when creating the subscription), and likewise update any other test references
(e.g., assertions or calls that expect that literal name such as checks against
spock.local_node) to use the generated name so tests remain correct if naming
rules change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/tap/t/012_zodan_basics.pl`:
- Around line 54-74: Replace the hardcoded subscription name 'sub_n2_n1' with a
generated name using spock.gen_sub_name to prevent drift: update the
psql_or_bail calls that invoke spock.sub_disable('sub_n2_n1') and
spock.sub_enable('sub_n2_n1') to compute the subscription name via
spock.gen_sub_name(...) (matching the same parameters used when creating the
subscription), and likewise update any other test references (e.g., assertions
or calls that expect that literal name such as checks against spock.local_node)
to use the generated name so tests remain correct if naming rules change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b4a48883-7741-4f0d-bfef-8f20aff169b2

📥 Commits

Reviewing files that changed from the base of the PR and between 582cb36 and d9dd91c.

📒 Files selected for processing (1)
  • tests/tap/t/012_zodan_basics.pl

Copy link
Copy Markdown
Contributor

@ibrarahmad ibrarahmad left a comment

Choose a reason for hiding this comment

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

LGTM, Just check If we need some docs adjustment or not.

@mason-sharp mason-sharp merged commit e567d89 into main Apr 14, 2026
10 checks passed
@mason-sharp mason-sharp deleted the fix/SPOC-503/sub-name branch April 14, 2026 16:33
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