Skip to content

fix: valid action syntax#1116

Closed
outerlook wants to merge 1 commit intomainfrom
fix/broken-ci
Closed

fix: valid action syntax#1116
outerlook wants to merge 1 commit intomainfrom
fix/broken-ci

Conversation

@outerlook
Copy link
Contributor

@outerlook outerlook commented Aug 20, 2025

Description

Related Problem

How Has This Been Tested?

Summary by CodeRabbit

  • New Features
    • Broadened access to the automated digest operation, making it callable without elevated privileges (subject to standard permissions).
    • No changes to the operation’s behavior or output; only visibility/access updated.

- Changed the visibility of the `auto_digest` action from private to public in the `020-digest-actions.sql` migration script, allowing it to be called directly from the CLI for verification purposes.
@outerlook outerlook self-assigned this Aug 20, 2025
@coderabbitai
Copy link

coderabbitai bot commented Aug 20, 2025

Walkthrough

Added PUBLIC visibility to the auto_digest action declaration in the SQL migration, changing its signature. No other logic, columns, or body content was modified.

Changes

Cohort / File(s) Summary of Changes
Migrations: digest action visibility
internal/migrations/020-digest-actions.sql
Updated action signature to include PUBLIC: CREATE OR REPLACE ACTION auto_digest() PUBLIC RETURNS TABLE(...); no logic/body changes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Assessment against linked issues

Objective Addressed Explanation
Fix CI failures from new auto_digest action causing broken tests (#1115) Visibility change may affect testability, but no direct evidence of test fixes in this diff.

Assessment against linked issues: Out-of-scope changes

(no out-of-scope functional changes identified)

Poem

I nibbled the schema with whiskered delight,
Made auto_digest PUBLIC, brought it to light.
Tests, may you hop now, steady and sure—
Carrots of green, CI to purr.
With a twitch of my nose, migrations take flight. 🥕🐇

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/broken-ci

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@outerlook outerlook changed the title fix: update auto_digest action visibility in migration script fix: valid action syntax Aug 20, 2025
@holdex
Copy link

holdex bot commented Aug 20, 2025

Bug Report Checklist

Status Commit Link Bug Author
✅ Submitted commit link @outerlook

@outerlook
Copy link
Contributor Author

@pr-time-tracker bug commit 38cdbb8 && bug author @outerlook

@outerlook outerlook requested a review from MicBun August 20, 2025 13:51
@holdex
Copy link

holdex bot commented Aug 20, 2025

Time Submission Status

Member Status Time Action Last Update
@outerlook ❌ Missing - ⚠️ Submit time -

@outerlook
Copy link
Contributor Author

oh, merged wrongly now

Copy link

@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.

Actionable comments posted: 1

🧹 Nitpick comments (3)
internal/migrations/020-digest-actions.sql (3)

4-8: Reassess exposure: PUBLIC may allow untrusted callers

If PUBLIC means globally invokable, this could become risky once the action performs deletions (hinted by total_deleted_rows). Consider restricting execution to the scheduler/maintenance role instead of PUBLIC, or add a guard to reject non-scheduler callers.

Can you confirm:

  • Which role the scheduler uses to invoke actions?
  • Whether non-scheduler clients could call this action in production?

If needed, I can propose a follow-up migration to tighten execution permissions once we confirm the engine’s authorization syntax for ACTIONs.


9-13: Implement leader-only guard before enabling real side effects

The TODO for leader enforcement is noted. Before turning this into a non-noop (deleting rows), add the leader check (or equivalent single-writer semaphore) to avoid concurrent runs across nodes.

If you share the idiomatic way your SQL engine exposes node identity and errors in ACTIONs, I can draft the guard snippet and tests.


4-14: Optional: annotate determinism/read-only if supported

Comment says “deterministic, read-only.” If your engine supports attributes (e.g., IMMUTABLE/STABLE, READ ONLY), consider declaring them to help the planner and to fail fast if future edits introduce writes.

Do ACTIONs support such attributes in this engine? If yes, I can update the declaration accordingly.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 1c67faa and dfb9349.

📒 Files selected for processing (1)
  • internal/migrations/020-digest-actions.sql (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-20T12:22:14.250Z
Learnt from: outerlook
PR: trufnetwork/node#1113
File: internal/migrations/020-digest-init.sql:3-11
Timestamp: 2025-08-20T12:22:14.250Z
Learning: In the trufnetwork/node repository, for the digest_config table in internal/migrations/020-digest-init.sql, the maintainer prefers to leave the table without initial seed rows, allowing the extension to handle the empty state case at runtime rather than seeding default configuration values in the migration.

Applied to files:

  • internal/migrations/020-digest-actions.sql
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: acceptance-test
🔇 Additional comments (1)
internal/migrations/020-digest-actions.sql (1)

4-8: Change aligns with PR goal to fix broken CI (visibility/syntax). LGTM

Assuming the engine expects an explicit visibility for actions callable by the scheduler, adding PUBLIC should address the invalid syntax/broken CI from #1115. No functional logic changed.

-- No-op, deterministic, read-only; used to verify wiring and scheduler calls

CREATE OR REPLACE ACTION auto_digest() RETURNS TABLE(
CREATE OR REPLACE ACTION auto_digest() PUBLIC RETURNS TABLE(
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Confirm placement/semantics of PUBLIC in ACTION signature

Good move to add visibility, but please double-check the grammar/order for your SQL engine. Some dialects place PUBLIC before ACTION or after RETURNS. Ensure this exact placement auto_digest() PUBLIC RETURNS TABLE(...) is valid.

Run this script to compare with other actions in the repo and validate ordering/consistency:


🏁 Script executed:

#!/bin/bash
# Find all ACTION declarations and show surrounding context to compare placement of visibility modifiers
rg -nP -C2 '(?i)^\s*create\s+or\s+replace\s+action\s+[a-zA-Z0-9_]+\s*\([^)]*\)\s*(public)?\s*returns\s+table' --type-add 'sql:*.sql' --type sql

# Also show any variants that put PUBLIC elsewhere (before ACTION or after RETURNS)
rg -nP -C2 '(?i)create\s+or\s+replace\s+(public\s+)?action|returns\s+table\s+public' --type sql

Length of output: 43543


Include VIEW in the auto_digest signature
The repo consistently uses PUBLIC VIEW RETURNS TABLE for table-returning actions (e.g. get_database_size). In internal/migrations/020-digest-actions.sql you have:

CREATE OR REPLACE ACTION auto_digest() PUBLIC RETURNS TABLE(

To match the grammar and other declarations, update it to:

CREATE OR REPLACE ACTION auto_digest() PUBLIC VIEW RETURNS TABLE(

• File: internal/migrations/020-digest-actions.sql, line 4

🤖 Prompt for AI Agents
In internal/migrations/020-digest-actions.sql around line 4, the ACTION
signature is missing the VIEW keyword; update the declaration to include VIEW so
it reads as "CREATE OR REPLACE ACTION auto_digest() PUBLIC VIEW RETURNS
TABLE(...)" to match the repository convention and correct grammar.

@MicBun
Copy link
Member

MicBun commented Aug 20, 2025

I just see this PR, the fix I include in https://github.com/trufnetwork/node/pull/1118/files#diff-23c216da563b1ef4f8ce0d1a5a6ddbd288e9d817f4ed64f03da208943c3cb143

I haven't test auto_digest properly yet. So maybe will need to be checked again in the next PR, with extension enabled.
@outerlook

@MicBun
Copy link
Member

MicBun commented Aug 20, 2025

Also fixed here:
#1117

@MicBun MicBun closed this Aug 20, 2025
@MicBun MicBun deleted the fix/broken-ci branch September 3, 2025 07:21
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.

Bug: broken tests

2 participants