Skip to content

fix: validate config string formats#3669

Open
Dexter2099 wants to merge 1 commit into
meltano:mainfrom
Dexter2099:codex/validate-config-string-formats
Open

fix: validate config string formats#3669
Dexter2099 wants to merge 1 commit into
meltano:mainfrom
Dexter2099:codex/validate-config-string-formats

Conversation

@Dexter2099

@Dexter2099 Dexter2099 commented Jun 5, 2026

Copy link
Copy Markdown

Fixes #1451.

Summary

  • Enable JSON Schema format checking when validating plugin configuration.
  • Add regression coverage showing an invalid date-time config value raises ConfigValidationError.
  • Update the shared core test tap fixture to use a valid RFC3339 date-time value for start_date.

Validation

  • uv run pytest tests/core/test_tap_class.py::test_config_errors -q
  • uv run pytest tests/core/test_tap_class.py tests/core/test_target_class.py tests/core/test_plugin_base.py tests/core/test_plugin_config.py tests/core/test_jsonschema_helpers.py -q
  • uv run pytest tests/core -q
  • pre-commit run --files singer_sdk/plugin_base.py tests/core/test_tap_class.py tests/core/conftest.py tests/core/test_streams.py
  • NOX_DEFAULT_VENV_BACKEND=uv nox -rs tests-3.11 -- tests/core

Summary by Sourcery

Enable strict JSON Schema format validation for plugin configuration and align tests with RFC3339-compliant date-time values.

Bug Fixes:

  • Ensure configuration validation checks JSON Schema formats such as date-time when validating plugin configs.

Tests:

  • Add regression coverage for invalid date-time configuration values and update core tap/stream test fixtures to use RFC3339-compliant start_date values.

@sourcery-ai

sourcery-ai Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Enables JSON Schema format checking for plugin configuration validation and updates tests/fixtures to use and assert correct RFC3339 date-time handling, including a regression test for invalid date-time values.

File-Level Changes

Change Details Files
Enable JSON Schema format checking during plugin configuration validation.
  • Update the JSONSchemaValidator instantiation to pass a format_checker so that string formats such as date-time are validated.
  • Ensure configuration validation now yields errors when values do not conform to declared JSON Schema formats.
singer_sdk/plugin_base.py
Add regression coverage to ensure invalid date-time config values fail validation.
  • Extend parametrized tap config error tests with a case where start_date has an invalid date-time string.
  • Assert that ConfigValidationError is raised and that the error message reflects the date-time format violation.
tests/core/test_tap_class.py
Align test fixtures and constants with valid RFC3339 date-time values for start_date.
  • Update the SimpleTestTap config fixture to use an RFC3339-compliant date-time string for start_date.
  • Adjust the CONFIG_START_DATE constant used by stream tests to match the new RFC3339 date-time format.
tests/core/conftest.py
tests/core/test_streams.py

Assessment against linked issues

Issue Objective Addressed Explanation
#1451 Enable JSON Schema format keyword validation (e.g., format: "date-time") during plugin configuration validation so that incorrectly formatted strings cause a config validation error.
#1451 Avoid breaking existing configurations that use a date-time JSON Schema format but provide values like "2021-01-01" (e.g., by relaxing the schema or using a union of date-time and date). The PR enables strict format checking by passing format_checker=JSONSchemaValidator.FORMAT_CHECKER to the validator but does not modify DateTimeType or schemas to allow date values as an alternative. Instead, it updates tests to use a fully RFC3339-compliant date-time string (2021-01-01T00:00:00Z), meaning existing user configs that use 2021-01-01 for a date-time field would now fail validation.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • The new invalid_date_time_format test asserts the exact jsonschema error string ("'not-a-date' is not a 'date-time'"), which may be brittle across jsonschema versions or implementations; consider matching on a more stable substring or pattern instead of the full message.
  • Enabling format_checker changes validation behavior for existing configs that previously passed; if this is expected, consider whether there should be a way to opt out or gate this behavior for plugins that intentionally use non‑RFC3339 date strings.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `invalid_date_time_format` test asserts the exact jsonschema error string (`"'not-a-date' is not a 'date-time'"`), which may be brittle across jsonschema versions or implementations; consider matching on a more stable substring or pattern instead of the full message.
- Enabling `format_checker` changes validation behavior for existing configs that previously passed; if this is expected, consider whether there should be a way to opt out or gate this behavior for plugins that intentionally use non‑RFC3339 date strings.

## Individual Comments

### Comment 1
<location path="tests/core/test_streams.py" line_range="37" />
<code_context>
     from tests.core.conftest import SimpleTestTap

-CONFIG_START_DATE = "2021-01-01"
+CONFIG_START_DATE = "2021-01-01T00:00:00Z"


</code_context>
<issue_to_address>
**suggestion (testing):** Consider centralizing the test `start_date` value to avoid drift between tests and fixtures

Since this value must stay in sync with the fixture’s `start_date`, consider defining it once (e.g., as a shared fixture or constant in `conftest.py`) and importing it here. That will prevent format drift across tests and simplify future format changes.

Suggested implementation:

```python
    from singer_sdk.helpers.types import Context, Record
    from tests.core.conftest import CONFIG_START_DATE, SimpleTestTap

```

To fully implement the centralization, you should also:

1. Define `CONFIG_START_DATE = "2021-01-01T00:00:00Z"` (or whatever value you prefer) in `tests/core/conftest.py`.
2. Ensure any fixtures or helper functions in `tests/core/conftest.py` that use a start date reference this `CONFIG_START_DATE` constant so the tests and fixtures remain synchronized.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread tests/core/test_streams.py Outdated
from tests.core.conftest import SimpleTestTap

CONFIG_START_DATE = "2021-01-01"
CONFIG_START_DATE = "2021-01-01T00:00:00Z"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (testing): Consider centralizing the test start_date value to avoid drift between tests and fixtures

Since this value must stay in sync with the fixture’s start_date, consider defining it once (e.g., as a shared fixture or constant in conftest.py) and importing it here. That will prevent format drift across tests and simplify future format changes.

Suggested implementation:

    from singer_sdk.helpers.types import Context, Record
    from tests.core.conftest import CONFIG_START_DATE, SimpleTestTap

To fully implement the centralization, you should also:

  1. Define CONFIG_START_DATE = "2021-01-01T00:00:00Z" (or whatever value you prefer) in tests/core/conftest.py.
  2. Ensure any fixtures or helper functions in tests/core/conftest.py that use a start date reference this CONFIG_START_DATE constant so the tests and fixtures remain synchronized.

@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.12%. Comparing base (bf02d4f) to head (245d8fc).
⚠️ Report is 22 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3669   +/-   ##
=======================================
  Coverage   94.12%   94.12%           
=======================================
  Files          73       73           
  Lines        6198     6198           
  Branches      762      762           
=======================================
  Hits         5834     5834           
  Misses        270      270           
  Partials       94       94           
Flag Coverage Δ
core 82.94% <100.00%> (ø)
end-to-end 76.02% <100.00%> (ø)
optional-components 44.82% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed-hq

codspeed-hq Bot commented Jun 5, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 8 untouched benchmarks


Comparing Dexter2099:codex/validate-config-string-formats (245d8fc) with main (bf02d4f)

Open in CodSpeed

@Dexter2099 Dexter2099 force-pushed the codex/validate-config-string-formats branch from 08ee240 to 245d8fc Compare June 5, 2026 22:41
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.

bug: String format is not validated in configuration

1 participant