graph-tooling
graph-tooling copied to clipboard
`graph add` should not modify `subgraph.yaml` on error
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
inita subgraph- Run
graph add <address> --start-block=invalid - Output should be similar to
Failed to run codegen: Command failed: yarn codegen - The
subgraph.yamlhas been updated with the new contract andstartBlockvalue is set toinvalid. - 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.