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

[airbyte_connection] [bug] MongoDB stream change produces error as primary key is pre-defined #107

Open
ivan-sukhomlyn opened this issue May 23, 2024 · 4 comments

Comments

@ivan-sukhomlyn
Copy link

After schema updating, the order of MongoDB stream representation in Terraform state changes, and it can not be rewritten due to the already defined primary key, even if it's not defined in the source code.

For example,
HCL

resource "airbyte_connection" "mongodb_bigquery" {
...
  configurations = {
    streams = [
      {
        name      = test_collection_1
        sync_mode = "incremental_deduped_history"
      },
      {
        name      = test_collection_2
        sync_mode = "incremental_deduped_history"
      }
    ]
  }

After schema updating, I got the following terraform plan:

  # airbyte_connection.mongodb_bigquery will be updated in-place
  ~ resource "airbyte_connection" "mongodb_bigquery" {
      ~ configurations                       = {
          ~ streams = [
              ~ {
                  ~ name         = "test_collection_2" -> "test_collection_1"
                    # (3 unchanged attributes hidden)
                },
              ~ {
                  ~ name         = "test_collection_1" -> "test_collection_2"
                    # (3 unchanged attributes hidden)
                },
            ]
        }
...
    }

terraform apply:

{"type":"https://reference.airbyte.com/reference/errors","detail":"The body of the request contains an invalid connection configuration. **Primary key for stream: test_collection_1 is already pre-defined.** Please do NOT include a primary key configuration for this stream.","title":"bad-request","status":400}
@ivan-sukhomlyn
Copy link
Author

The same situation is for the notion source

@ivan-sukhomlyn
Copy link
Author

can be omitted by the following definition

resource "airbyte_connection" "mongodb_bigquery" {
...
  configurations = {
    streams = [
        name        = "test_collection_2"
        sync_mode   = "incremental_deduped_history"
        primary_key = null
      }
    ]
  }
}

@ivan-sukhomlyn
Copy link
Author

Fixed by #128

@ivan-sukhomlyn
Copy link
Author

The error is due to the already pre-defined primary key still being present.

╷
│ Error: failure to invoke API
│ 
│   with airbyte_connection.mongodb_bigquery
│ 
│ unknown status code returned: Status 400
│ {"type":"https://reference.airbyte.com/reference/errors","detail":"The body of the request contains an invalid connection configuration. Primary key for stream:
│ { some_stream } is already pre-defined. Please do NOT include a primary key configuration for this stream.","title":"bad-request","status":400}

@ivan-sukhomlyn ivan-sukhomlyn reopened this Sep 4, 2024
@ivan-sukhomlyn ivan-sukhomlyn changed the title [airbyte_connection] [bug] MongoDB streams order change produces Terraform error [airbyte_connection] [bug] MongoDB stream change produces error as primary key is pre-defined Sep 6, 2024
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

No branches or pull requests

1 participant