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

[BUG]: Cannot omit migrate.json5, but command line options are overridden #20

Open
brewencoded opened this issue Oct 29, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@brewencoded
Copy link

Describe the bug
After looking into the source code, I found the following:

arn gets set here: https://github.com/sensedeep/onetable-cli/blob/main/src/cli.js#L431
config is pulled in here: https://github.com/sensedeep/onetable-cli/blob/main/src/cli.js#L111
arn is checked here: https://github.com/sensedeep/onetable-cli/blob/main/src/cli.js#L134

If the arn is defined, it creates the Proxy object which is what we want for the controller. The problem is that getConfig doesn't get the arn that was set by parseArgs. So even if I use --arn it will skip the logic for creating the Proxy. If I put an empty arn property in the migrate.json5 file, it will create a Proxy, but it passes the empty string to the constructor which overrides this.arn: https://github.com/sensedeep/onetable-cli/blob/main/src/cli.js#L551

So the problem seems to be that --arn does not get evaluated along side the arn property. I'm not sure if it gets used outside of being set in the args. I didn't have the time look thoroughly, but it's possible that many of the args aren't being blended with config values.

To Reproduce
Steps to reproduce the behavior:

  1. Include your OneTable schema: Schema does not matter for bug
  2. Include actual onetable command used and output generated:
    ../../node_modules/.bin/onetable --debug --force --config ./migrate.json5 --arn $FUNCTION_ARN --table $TABLE_NAME "up"
  3. Run command with --debug and include additional trace:
    Cannot communicate with DynamoDB "<table-name>" at "placeholder"

Expected behavior
I expected that any command line arguments would would be blended with migrate.json5 properties that were not supplied. Instead, CLI.init() only evaluates the json properties when determining whether to use Proxy.

Environment (please complete the following information):

  • OS: Mac Ventura
  • Node Version: 20

Additional context
What I'm trying to accomplish:
I am trying to run onetable-migrate in a CI/CD environment. I can pull the current version using onetable status and the desired version using version in my schema file. I can use that to determine whether this is a migration up or down.

I also get the arn of my controller via aws cli and the table name is calculated after deployment based on stage names. So I can not have my infrastructure configurations in the json5 file. I tried using the various command line options like --arn, and --table.

In the meantime, I might have to create the migrate.json5 file at runtime to workaround this behavior, unless you have some other suggestions.

@mobsense mobsense added the bug Something isn't working label Nov 15, 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

2 participants