fix: validate config string formats#3669
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideEnables JSON Schema format checking for plugin configuration validation and updates tests/fixtures to use and assert correct RFC3339 File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The new
invalid_date_time_formattest 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_checkerchanges 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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| from tests.core.conftest import SimpleTestTap | ||
|
|
||
| CONFIG_START_DATE = "2021-01-01" | ||
| CONFIG_START_DATE = "2021-01-01T00:00:00Z" |
There was a problem hiding this comment.
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, SimpleTestTapTo fully implement the centralization, you should also:
- Define
CONFIG_START_DATE = "2021-01-01T00:00:00Z"(or whatever value you prefer) intests/core/conftest.py. - Ensure any fixtures or helper functions in
tests/core/conftest.pythat use a start date reference thisCONFIG_START_DATEconstant so the tests and fixtures remain synchronized.
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
08ee240 to
245d8fc
Compare
Fixes #1451.
Summary
date-timeconfig value raisesConfigValidationError.date-timevalue forstart_date.Validation
uv run pytest tests/core/test_tap_class.py::test_config_errors -quv 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 -quv run pytest tests/core -qpre-commit run --files singer_sdk/plugin_base.py tests/core/test_tap_class.py tests/core/conftest.py tests/core/test_streams.pyNOX_DEFAULT_VENV_BACKEND=uv nox -rs tests-3.11 -- tests/coreSummary by Sourcery
Enable strict JSON Schema format validation for plugin configuration and align tests with RFC3339-compliant date-time values.
Bug Fixes:
Tests: