Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SELECT specific columns from ORGANIZATION table in getOrganization #386

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

HaJunYoo
Copy link

@HaJunYoo HaJunYoo commented Jan 31, 2025

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 tombstone column contains UUID values
  • Code attempts to read this field as boolean type
  • Type conversion failure triggers 500 error on /api/v1/instance_configuration endpoint
  • 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?

  • YES 💚
  • NO ❌

@CLAassistant
Copy link

CLAassistant commented Jan 31, 2025

CLA assistant check
All committers have signed the CLA.

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.

3 participants