Skip to content

Fix STI subclass bug in FieldEncryptor#before_create - #5616

Merged
jochenehret merged 1 commit into
mainfrom
fix_null_encryption_key_labels
Nov 3, 2026
Merged

jochenehret merged 1 commit into
mainfrom
fix_null_encryption_key_labels

Conversation

@jochenehret

@jochenehret jochenehret commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor
  • A short explanation of the proposed change:

    ManagedServiceInstance and UserProvidedServiceInstance are STI subclasses
    of ServiceInstance, but only "ServiceInstance" is registered in
    encrypted_classes. The before_create hook checked only self.class.name,
    so precursor INSERTs for managed service instances never set
    encryption_key_label, leaving it NULL permanently when the failure path
    skipped the credentials= setter.

    Fix: walk the ancestor chain instead of checking the class name directly.

  • An explanation of the use cases your change solves

On a productive system, there are often a few service_instance rows without an encryption_key_label, e.g. when the service instance creation failed. In this case, the check_cc_database_key errand reports that some rows need re-encryption and then you have to start the rotate_cc_database_key errand. We would like to avoid this overhead. Assigning the current encryption_key_label even if the creation fails solves the problem.

This PR has been created with Claude Code.

  ManagedServiceInstance and UserProvidedServiceInstance are STI subclasses
  of ServiceInstance, but only "ServiceInstance" is registered in
  encrypted_classes. The before_create hook checked only self.class.name,
  so precursor INSERTs for managed service instances never set
  encryption_key_label, leaving it NULL permanently when the failure path
  skipped the credentials= setter.

  Fix: walk the ancestor chain instead of checking the class name directly.
@jochenehret
jochenehret force-pushed the fix_null_encryption_key_labels branch from bec370f to bced62b Compare November 2, 2026 14:30
@jochenehret
jochenehret requested a review from a team November 3, 2026 07:39
@jochenehret
jochenehret merged commit af2d605 into main Nov 3, 2026
11 checks passed
ari-wg-gitbot added a commit to cloudfoundry/capi-release that referenced this pull request Nov 3, 2026
Changes in cloud_controller_ng:

- Fix STI subclass bug in FieldEncryptor#before_create
    PR: cloudfoundry/cloud_controller_ng#5616
    Author: Jochen Ehret <jochen.ehret@sap.com>
@moleske
moleske deleted the fix_null_encryption_key_labels branch November 3, 2026 16:10
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