Skip to content

refactor(geo_enrichment): layer trigger args, TOML and request body through load_config - #171

Merged
caterryan merged 11 commits into
mainfrom
refactor/geo-enrichment-config
Sep 16, 2026
Merged

caterryan merged 11 commits into
mainfrom
refactor/geo-enrichment-config

Conversation

@caterryan

@caterryan caterryan commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

Rewrites how geo_enrichment loads its configuration, using the config, sources and validation modules from influxdata-plugin-utils 0.4.0. Supersedes #170.

  • Trigger arguments, the TOML file they name, and the request body are merged in that order. Later layers win.
  • The HTTP trigger now reads its trigger arguments. A trigger created without arguments still takes everything from the body.
  • config_file_path is a trigger argument only. Sending it in the body is a 400, as is any unknown field.
  • The write trigger no longer validates the backfill fields.
  • max_radius_m and grid_precision no longer accept -1. Leave them unset for the default.
  • Version bumped to 0.2.0.

🤖 Generated with Claude Code

caterryan and others added 11 commits September 16, 2026 12:58
…hrough load_config

Replace normalize_config with a declarative VALIDATORS list plus
prepare_config for the cross-setting checks and derived values. Each source
is read by its own influxdata-plugin-utils parser and the layers are handed
to load_config lowest precedence first: trigger arguments, then the TOML
file they name, then on the HTTP trigger the request body.

config_file_path is now a trigger argument on both triggers and is refused
in the request body. The HTTP trigger gains an http_args_config block so a
backfill trigger can hold the defaults each request overrides.

Bump to 0.2.0.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ields

One validator list served both triggers, so a TOML shared with the HTTP
endpoint that carried a half window or a bad batch_size stopped live
enrichment over fields process_writes never reads. The list is now
SETTING_VALIDATORS plus BACKFILL_VALIDATORS; the write trigger applies only
the first and the HTTP trigger the sum of both.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The body KeySpec had a denylist and no allowlist, so unknown="reject" fired
for config_file_path alone and a misspelled field such as "forse" was
accepted, ignored, and left in cfg while the caller believed it took
effect. The body now carries the settings and backfill fields by name and
refuses anything else, config_file_path included.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…P trigger

The http_args_config entries for source_measurements and output_columns
were copied from the write trigger: the example named two tables and the
description spoke of rows in the batch, neither of which applies to a
backfill that handles one table per call. Both were also marked required,
although the README's own example creates the trigger bare and lets the
body or the TOML file supply them; Explorer would have inserted them as
non-removable arguments. They are now optional, with the requirement
described on the merged configuration.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… back

Expressing them as Validator(required=True, when=...) replaced messages
that named the setting making the demand, and for target_measurement said
why, with the library's fixed "<name> is required". prepare_config's own
docstring places refusals that name a second setting there, so the three
move back with their 0.1.x wording. The start/end pairing stays declarative
in BACKFILL_VALIDATORS, since only the HTTP trigger may apply it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A module-level helper named text was shadowed by locals and parameters of
the same name in five functions. None of them called the helper, so
nothing was broken yet, but the next edit to one of them would have met an
UnboundLocalError. trimmed() says what it does and collides with nothing.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
cast=trimmed stringified whatever TOML delivered, so an unquoted
start = 2026-08-01T00:00:00.123456789Z became str(datetime): space
separated, +00:00, and truncated to microseconds, quietly breaking the
nanosecond precision the README promises. start and end now take a
timestamp_text cast that refuses anything but a string and names the fix.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…pected

parse_delimited_list and parse_key_value stringify what they do not
expect, so a JSON object for source_measurements, a non-string list item,
or a null or nested value inside an output_columns object became garbage
identifiers instead of a refusal. measurement_list and output_column_map
now check the shape before handing it on.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ile_path

The README and the test explained the refusal as keeping a caller from
naming any file the server can read, but reference_file is body-settable,
accepts absolute paths and is opened server-side, so that reason did not
hold. The path is refused because it selects a layer rather than setting a
value: a body that could pick which file the trigger reads would take the
trigger's configuration out of the operator's hands.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…setting

Both the source parsers and the layer merge drop an empty string or null as
"not provided", so a body sending target_measurement="" still writes to
the table the trigger names, with a 200. A reset mechanism is a library
design question; for now the README states the limitation and its
workaround, and a test pins the behavior so a change to it is deliberate.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… asserts

The trigger-holds-the-setup, body-carries-the-window flow the README and
the TOML example advertise had no test: every backfill() call sent the
full configuration in the body. It now has one, driven through a config
file on the trigger.

test_unusable_request_body_is_a_bad_request got its 400 for None and ""
only because no trigger was configured; those are a 200 with one, and the
malformed bodies now assert their message against a configured trigger.
test_the_body_overrides_the_trigger_arguments would have passed had the
arguments been ignored; a second argument now proves they were read.
test_a_blank_argument_leaves_the_default_in_place asserts the value it
passed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@caterryan
caterryan merged commit b5e2100 into main Sep 16, 2026
7 checks passed
@caterryan
caterryan deleted the refactor/geo-enrichment-config branch September 16, 2026 19:53
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

Successfully merging this pull request may close these issues.

2 participants