Skip to content

add limit for codgen#2

Merged
lmcmz merged 2 commits intomainfrom
fix-codgen
Jul 28, 2025
Merged

add limit for codgen#2
lmcmz merged 2 commits intomainfrom
fix-codgen

Conversation

@caosbad
Copy link
Collaborator

@caosbad caosbad commented Jul 28, 2025

Summary by CodeRabbit

  • New Features
    • Increased the default request limit for generated TypeScript query and transaction functions, enabling retrieval of larger data sets in a single call.

@caosbad caosbad requested a review from lmcmz July 28, 2025 01:07
@coderabbitai
Copy link

coderabbitai bot commented Jul 28, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

A fixed limit: 9999 property was added to the configuration objects in the TypeScript code templates generated by the Go generator. This affects both query and transaction function templates, modifying the configuration passed to the Flow client library for generated TypeScript functions.

Changes

Cohort / Files Change Summary
TypeScript generator update
internal/generator/typescript/generator.go
Added limit: 9999 to the config objects in function templates for both query and transaction cases in generated TypeScript code.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

A sprinkle of limit, a dash of delight,
9999 now shines so bright.
In configs it sits, both query and send,
Making sure requests don’t quickly end.
The generator hops, its work now complete—
With every new script, the change is sweet! 🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 61bacf3 and 59c930d.

📒 Files selected for processing (1)
  • internal/generator/typescript/generator.go (2 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-codgen

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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

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

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: 2

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f63d5f5 and 61bacf3.

📒 Files selected for processing (1)
  • internal/generator/typescript/generator.go (2 hunks)
🔇 Additional comments (1)
internal/generator/typescript/generator.go (1)

119-119: Explicitly setting the default FCL computation limit is safe

The added limit: 9999 simply mirrors FCL’s default maximum computation steps for script queries (9999), so existing clients won’t see any behavior change. Explicitly including it in the generated code improves clarity—developers can still override the limit when higher resources are needed.

arg({{.Name}}, {{getFCLType .TypeStr}}),
{{- end}}
],
limit: 9999,
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Make the limit configurable and document its purpose.

The hardcoded limit: 9999 lacks flexibility and documentation. Consider:

  1. Make it configurable: Allow users to specify different limits for different scripts
  2. Add documentation: Explain what this limit controls (execution units, gas, etc.)
  3. Provide sensible defaults: Research appropriate default values for different script types
-	  	limit: 9999,
+	  	limit: {{if $func.Limit}}{{$func.Limit}}{{else}}9999{{end}},

Also consider adding a field to the TypeScriptFunction struct to support per-function limits:

type TypeScriptFunction struct {
	Name       string
	Parameters []TypeScriptParameter
	ReturnType string
	Base64     string
	Type       string
	Limit      *int // Optional limit override
}
🤖 Prompt for AI Agents
In internal/generator/typescript/generator.go at line 119, the limit value is
hardcoded to 9999, which reduces flexibility and lacks documentation. To fix
this, add a configurable limit field to the TypeScriptFunction struct to allow
per-function limit overrides, update the code to use this configurable limit
instead of the hardcoded value, and add comments explaining what the limit
controls (e.g., execution units or gas). Also, set a sensible default limit
value when none is provided.

arg({{.Name}}, {{getFCLType .TypeStr}}),
{{- end}}
],
limit: 9999,
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider different limits for transactions vs queries.

Using the same hardcoded limit for both transactions and queries may not be optimal. Transactions typically have different resource requirements and cost implications.

Consider:

  1. Separate configuration: Use different default limits for transactions vs queries
  2. Research-based defaults: Investigate appropriate limits based on Flow network specifications
  3. Runtime configurability: Allow limits to be set at the service level
-	  	limit: 9999,
+	  	limit: {{if $func.Limit}}{{$func.Limit}}{{else}}{{if eq $func.Type "transaction"}}15000{{else}}5000{{end}}{{end}},

This example uses different defaults but still allows per-function overrides.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
limit: 9999,
limit: {{if $func.Limit}}{{$func.Limit}}{{else}}{{if eq $func.Type "transaction"}}15000{{else}}5000{{end}}{{end}},
🤖 Prompt for AI Agents
In internal/generator/typescript/generator.go at line 135, the current hardcoded
limit of 9999 is used for both transactions and queries, which is not optimal.
Refactor the code to define separate default limits for transactions and
queries, ideally based on Flow network specifications. Implement these as
configurable parameters at the service level to allow overrides per function,
ensuring flexibility and better resource management.

@lmcmz lmcmz merged commit 64c4560 into main Jul 28, 2025
1 of 2 checks passed
@lmcmz lmcmz deleted the fix-codgen branch July 28, 2025 05:12
zenabot27 pushed a commit to zenabot27/cadence-codegen that referenced this pull request Feb 15, 2026
fix: allow same version in npm publish workflow
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