Skip to content

fix: sync config validation content#54

Merged
stevensJourney merged 5 commits into
mainfrom
fix-sync-config-validations
Jun 9, 2026
Merged

fix: sync config validation content#54
stevensJourney merged 5 commits into
mainfrom
fix-sync-config-validations

Conversation

@stevensJourney

Copy link
Copy Markdown
Collaborator

fixes #49

The PowerSync CLI validates Sync config by calling a running instance's /api/admin/v1/validate route. This provides Sync config validation errors and warnings which optionally map to the start and end character offset positions in the sync config content.

The current implementation for mapping from the service provided character offset position to a Line + Column position span is quite messy. This refactors the mapping implementation to avoid situations where critical warning and error details are omitted from being displayed.

The general flow now is to:

Request a base validation response from the /api/admin/v1/validate route. If character based positions are provided, we can enrich the message field to contain a line snippet and caret indicator.

For example, the message:

This table could not be found in the source schema.

Will become

This table could not be found in the source schema.
      - SELECT * FROM todossss
                      ^

We then map the character offsets (if provided) to the corresponding line and column span. The implementation then diverges for the powersync validate command and the built-in Sync Config editor.

For the powersync validate command: The output will prepend a text [Line XXX, Column YYY] string to the message. Resulting in the following output

✓ Validate Configuration Schema
✓ Test Connections
  • [warning] Connection tests are not currently supported for self-hosted projects.
✓ Validate Sync Config
  • [warning] Table "public"."todossss" not found.
  • [warning] [Line 14, Column 23]: This table could not be found in the source schema.
      - SELECT * FROM todossss
                      ^

The Sync Config editor will place Monaco Markers at the location/span of errors in the editor. The message shown here will not include any line/column information - that is conveyed by the span.

image

The Validation Details section will summarize all errors and warnings. Items which have positional information will indicate the relevant Line number. Items which don't have positional information, will not show any line item. This is particularly relevant from Syntax errors (when reported from the /api/admin/v1/validate route)

image

AI Usage. I manually made the main changes to the function structure and types. I then used Codex GPT 5.5 to cleanup comments, stale variable names and update the front-end widgets.

@stevensJourney stevensJourney marked this pull request as ready for review June 9, 2026 10:07
@stevensJourney stevensJourney requested a review from LucDeCaf June 9, 2026 10:07
LucDeCaf
LucDeCaf previously approved these changes Jun 9, 2026

@LucDeCaf LucDeCaf 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.

This looks a lot nicer than before! just some minor naming nitpicks.

Comment thread packages/cli-core/src/api/validate-sync-config.ts Outdated
Comment thread packages/cli-core/src/api/validate-sync-config.ts Outdated
Comment thread packages/cli-core/src/api/validate-sync-config.ts Outdated
@stevensJourney stevensJourney merged commit 4eea4ee into main Jun 9, 2026
6 checks passed
@stevensJourney stevensJourney deleted the fix-sync-config-validations branch June 9, 2026 14:27
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.

Default validate output strips crucial error info

2 participants