airbyte-platform
airbyte-platform copied to clipboard
SELECT specific columns from ORGANIZATION table in getOrganization
trafficstars
What
During Airbyte helm upgrade from 1.2.0 to 1.4.0, a type mismatch error occurred between code and database schema, causing web server access failure.
Root Cause
- Organization table's
tombstonecolumn contains UUID values - Code attempts to read this field as boolean type
- Type conversion failure triggers 500 error on
/api/v1/instance_configurationendpoint - This occurs during organization data fetch operations
Migration Issue
- Database schema changes were required but not properly applied
- Flyway migration V0_50_24_003 (V0_50_24_003__AddPbaAndOrgBillingColumnsToOrganizationTable) should have added new columns:
- 'pba' column
- 'org_level_billing' column
- Incomplete migration led to schema inconsistency in tombstone column
Web server became inaccessible due to the failed type conversion between UUID and boolean in the organization table.
Error message:
Internal Server Error: SQL [select * from "public"."organization" left outer join "public"."sso_config" on "public"."organization"."id" = "public"."sso_config"."organization_id" where "public"."organization"."id" = cast(? as uuid)]; Error while reading field: "public"."organization"."tombstone", at JDBC index: 9
Caused by: org.postgresql.util.PSQLException: Cannot cast to boolean: "4f74841b-3fa8-476c-9102-67a80be8a042"
How
While fixing the incomplete Flyway migration is the primary solution, improving query patterns can help prevent similar issues:
Code Changes
// From: Using asterisk() which includes all columns
.select(asterisk())
// To: Explicitly selecting required columns
.select(
ORGANIZATION.ID,
ORGANIZATION.NAME,
ORGANIZATION.EMAIL,
ORGANIZATION.USER_ID,
SSO_CONFIG.KEYCLOAK_REALM
)
- Earlier detection of schema-code mismatches through explicit column mapping
- Reduced risk of unexpected type conversion issues
Recommended reading order
- OrganizationPersistence.java
Can this PR be safely reverted and rolled back?
- [x] YES 💚
- [ ] NO ❌