fix: improve yaml load for sinks.max_retry_count, sinks.active_backfill and http_endpoints.encrypted_headers#1432
Conversation
28c6b5d to
1228857
Compare
As handling `active_backfill` seems to be entirely unsupported we are ignoring that field for now until we have a proper implementation
1228857 to
1b90bec
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR improves the YAML configuration loader so that problematic fields do not cause failures during configuration load.
- Ignores nil values for max_retry_count instead of erroring.
- Temporarily ignores active_backfill and encrypted_headers until proper support is implemented.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| test/sequin_web/controllers/yaml_controller_test.exs | Adds a comprehensive test case covering various configuration fields. |
| lib/sequin/transforms/transforms.ex | Updates handling for encrypted_headers, max_retry_count (nil), and active_backfill based on current requirements. |
735b756 to
8717dd0
Compare
8717dd0 to
6f6cc76
Compare
|
I just noticed that some tests are failing that are testing proper loading for
Example test https://github.com/sequinstream/sequin/blob/main/test/sequin/yaml_loader_test.exs#L334-L343 |
| defp encrypted_headers(%HttpEndpoint{encrypted_headers: encrypted_headers}) | ||
| when is_map(encrypted_headers) and map_size(encrypted_headers) == 0, | ||
| do: %{} | ||
|
|
lib/sequin/transforms/transforms.ex
Outdated
| # Ignore encrypted_headers until encryption/decryption works | ||
| "encrypted_headers" -> | ||
| case parse_headers(value) do | ||
| {:ok, headers} -> {:cont, {:ok, Map.put(acc, :encrypted_headers, headers)}} | ||
| {:error, error} -> {:halt, {:error, error}} | ||
| end | ||
| {:cont, {:ok, acc}} |
There was a problem hiding this comment.
I'm going to revert this before merging.
In our sequin config export, we mention that some fields are not supported - this is one of them. You're right, we export is as a binary, just a sha of the secret. This is not ideal, but users are definitely using this field for their imports.
We want to improve secret handling here: #1298
| "max_retry_count" when is_nil(value) -> | ||
| {:cont, {:ok, acc}} |
81d3348 to
73b16b6
Compare
73b16b6 to
935deb8
Compare
|
@davoclavo note I also fixed the tests -- a lot of our database create paths actually connect to the db and check its configuration. So we need to reference test tables that we know are in the database (see test/support/unboxed_repo/migrations/20240816005458_create_test_tables.exs and an example model in test/support/models/character.ex) So, I modified to refer to existing tables: |
|
@acco Thanks for letting me know and making some changes! I just want to point out that there are still issues with the encrypted headers, so I am unsure people are able to use them for their imports currently! Just added steps to replicate in #1442 in order to get to the bottom of this. I will start my investigation, but let me know if you have any pointers, or if you make any progress on this. |
While testing out CLI export->plan functionality, I detected a couple of issues when trying to load a config from a yaml.
sinks.max_retry_count- if is set to nil (as it seems its the default) the loader fails with an error stating that it should be greater than 0sinks.active_backfill- if is present, and set to any value, the loader fails. I suggest to ignore this field for now until we support managing backfills via the yaml.http_endpoints.encrypted_headers- seems to be serialized as a string/binary (even if the map is empty, as it seems is the default) - causing to failparse_headersvalidation. I suggest ignoring this field for now, unless we want to handle encrypting/decrypting them properly3.1. I also made a change to match if encrypted headers is an empty map, as opposed to
niland serialize them as an empty mapI added a simple test that includes a single resource of each, mostly created with default settings.
For a future iteration of an improved but similar check I would suggest to write a test that creates a bunch of records and combinations (
databases,change_retentions,sinks,http_endpoint,functions); then assert that exporting->loading works. That way we can test that if the exporting/serializing logic changes, it is still compatible with the loading/deserializing logic and viceversa.