Skip to content

Conversation

@petergithub
Copy link
Contributor

Fix issue "missing required type field" with dsn in configuration file dbhub.toml #131

When using DSN-based configuration in TOML files without explicit 'type' fields, the /api/sources endpoint was failing with "missing required type field" errors. This fix allows the endpoint to work correctly with DSN-only configurations by extracting the database type from the protocol portion of the DSN string.

Changes:

  • Add getDatabaseTypeFromDSN() utility function to dsn-obfuscate.ts
  • Use centralized type inference in transformSourceConfig()
  • Handle both 'postgres' and 'postgresql' protocols as PostgreSQL
  • Maintain backward compatibility with explicit type configurations

Fixes API endpoint failure for DSN-only TOML configurations.

When using DSN-based configuration in TOML files without explicit
'type' fields, the /api/sources endpoint was failing with "missing
required type field" errors. This fix allows the endpoint to work
correctly with DSN-only configurations by extracting the database
type from the protocol portion of the DSN string.

Changes:
- Add getDatabaseTypeFromDSN() utility function to dsn-obfuscate.ts
- Use centralized type inference in transformSourceConfig()
- Handle both 'postgres' and 'postgresql' protocols as PostgreSQL
- Maintain backward compatibility with explicit type configurations

Fixes API endpoint failure for DSN-only TOML configurations.
Copy link
Contributor

@tianzhou tianzhou left a comment

Choose a reason for hiding this comment

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

LGTM

@tianzhou tianzhou merged commit 0412761 into bytebase:main Nov 23, 2025
2 checks passed
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