Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graph add should not modify subgraph.yaml on error #1779

Open
0237h opened this issue Nov 29, 2024 · 0 comments
Open

graph add should not modify subgraph.yaml on error #1779

0237h opened this issue Nov 29, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@0237h
Copy link
Collaborator

0237h commented Nov 29, 2024

Which packages are impacted by your issue?

@graphprotocol/graph-cli

Describe the issue

If incorrect parameters are passed to the graph add command it will write these first to the subgraph.yaml before calling the codegen subcommand which will fail.

The subgraph.yaml is then left in an incorrect state and is not able to be loaded (with a second call to graph add for example) as the validate function fails.

Reproduction

cli

Steps to Reproduce the Bug or Issue

  1. init a subgraph
  2. Run graph add <address> --start-block=invalid
  3. Output should be similar to Failed to run codegen: Command failed: yarn codegen
  4. The subgraph.yaml has been updated with the new contract and startBlock value is set to invalid.
  5. Running the command again should lead to this error
Error: Error in subgraph.yaml:

      Path: dataSources > X > source > startBlock
      Expected BigInt, found string:
      invalid

Expected behavior

The command should not modify the original subgraph.yaml if it leaves it in a invalid state.

Screenshots or Videos

No response

Platform

  • @graphprotocol/* version(s): 0.90.1

Subgraph Manifest

No response

Subgraph GraphQL Schema

No response

Additional context

Possible solutions

  • Validate all parameters to make sure the values are valid.
  • Backup the original manifest and restore in case of errors.
@0237h 0237h added the bug Something isn't working label Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant