Skip to content

Improve error messages on invalid YAML nodes#612

Merged
simolus3 merged 1 commit intomainfrom
improve-error-messages-on-invalid-yaml-type
Apr 22, 2026
Merged

Improve error messages on invalid YAML nodes#612
simolus3 merged 1 commit intomainfrom
improve-error-messages-on-invalid-yaml-type

Conversation

@simolus3
Copy link
Copy Markdown
Contributor

In a few places in SyncConfigFromYaml, we use unsafe TypeScript casts trusting that nodes we expect to be yaml scalars are of the correct type.

When a node that isn't a scalar (e.g. a YamlSeq or a YamlMap) is used there, we still call toString() and try to parse it as SQL. toString() returns a JSON array/object in that case though, causing us to report absurd parser errors. This adds a check to actually verify that we're dealing with scalars, and reports an error message at the appropriate location if that's not the case.

Additionally, this skips the schema validation run if there we uncovered fatal errors. This reduces duplicate warnings now that we check most node types directly. It's not ideal because it means that fixing an error could cause us to report additional ones (e.g. if there's a syntax error in SQL and an additional property), but I think this is still an improvement for most cases. An ideal solution would probably be to handwrite a specialized schema check reporting errors with yaml nodes.

@simolus3 simolus3 requested a review from rkistner April 21, 2026 15:49
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 21, 2026

🦋 Changeset detected

Latest commit: 381894c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 18 packages
Name Type
@powersync/service-sync-rules Patch
@powersync/service-jpgwire Patch
@powersync/service-core-tests Patch
@powersync/service-core Patch
@powersync/lib-services-framework Patch
@powersync/service-module-mongodb-storage Patch
@powersync/service-module-mongodb Patch
@powersync/service-module-mssql Patch
@powersync/service-module-mysql Patch
@powersync/service-module-postgres-storage Patch
@powersync/service-module-postgres Patch
@powersync/lib-service-postgres Patch
@powersync/service-module-core Patch
@powersync/service-image Patch
test-client Patch
@powersync/service-rsocket-router Patch
@powersync/lib-service-mongodb Patch
@powersync/service-schema Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@simolus3 simolus3 merged commit 9e474d3 into main Apr 22, 2026
44 checks passed
@simolus3 simolus3 deleted the improve-error-messages-on-invalid-yaml-type branch April 22, 2026 13:04
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