Repository navigation
refactor: use @heroku/sdk for data:pg:credentials commands - #4017
Merged
Merged
Conversation
|
This PR is labeled size/XL (1988 lines of code churn, excluding docs, Large PRs are harder to review well. If it can be split into smaller, independently reviewable pieces, consider doing so. This is a suggestion, not a blocker — the check still passes. |
jdodson
approved these changes
Oct 27, 2026
Contributor
There was a problem hiding this comment.
Approved.
Manual tests all pass, good job.
AI had one thing it considers a blocker. Worth looking into.
- Data-service configuration regression: migrated credential calls do not preserve the configured data host or HEROKU_DATA_CONTROL_PLANE header. This can break environments using those overrides.
Contributor
Author
@jdodson This will be addressed in W-24610335 |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR migrates the
data:pg:credentialscommands —create,destroy,index,rotate,url— to@heroku/sdk(part 2 of thedata:pgsubcommand migration, following #4001), replacing rawthis.heroku/this.dataApicalls andheroku-cli-util'sutils.AddonResolver/utils.pghelpers with the SDK'sdatabaseCredentialExtensions.Command Changes
create.ts,destroy.ts,index.ts,rotate.ts, andurl.tsnow calldata.databaseCredential.{create,destroy,list,rotate,getUrl}viacreateSDK(this.heroku, {extensions: [databaseCredentialExtensions]}), instead of resolving the add-on and building REST paths by hand.data:pg:credentials:indexdetects non-Advanced-tier databases via the SDK'sNotAdvancedDatabaseError(instead of an explicit tier check before fetching credentials) and still suggestspg:credentialsas before.data:pg:credentials:rotateis restructured around abeforeRotatecallback passed todata.databaseCredential.rotate, which now owns resolving credentials/attachments and building the confirmation preview; the command's privategetCredsAndAttachments/getCredToRotatemethods are removed since the SDK resolves and previews the rotation internally.data:pg:credentials:urlnow readscredentialConnectionInfo.{database,host,port,user,password,url,credName}directly fromdata.databaseCredential.getUrl(...), instead of fetching raw credential info and building thepostgres://URL by hand.src/lib/data/parse-attachment-factors.tsand its test — attachment-namespace parsing now comes from@heroku/sdk/resources/data/postgres-database'sparseAttachmentFactors.Test Changes
nocktomockSDKData/mockSDKstubs (test/helpers/mock-sdk.ts), with mocked resolve/reject shapes to match the SDK's return typesV12-CHANGES.mddata:pg:credentials:urlanddata:pg:credentials:destroyerror messages are now plain, uncolored text, since the SDK throws plainErrors for these cases.Note:
src/commands/data/pg/attachments/create.tsandsrc/commands/pg/credentials.tsaren't migrated in this PR, so their use ofsortByLeaderAndName/sortByOwnerAndName/presentCredentialAttachments(previously imported from now-SDK-typedcredential-utils.ts/lib/pg/util.ts) is temporarily inlined with a// TODO: Remove this once ... is migrated to use the SDKcomment, to avoid taking on their migration here.Type of Change
Breaking Changes (major semver update)
!after your change type to denote a change that breaks current behaviorFeature Additions (minor semver update)
Patch Updates (patch semver update)
Testing
Notes:
Requires access to a Heroku app with an Advanced-tier database and a classic (non-Essential) tier database.
Setup:
npm i && npm run buildSteps:
Advanced-tier database
data:pg:attachments:create/pg:psqlcommands print with the right namesmy-credentialmy-credential's host/port/user/passwordmy-credentialis no longer listedClassic (non-Essential) tier database
addons:attach/pg:psqlcommands print with the right namespg:credentialswith the correct database name instead of listing credentialsmy-credentialmy-credential's host/port/user/passwordmy-credentialis no longer listedScreenshots (if applicable)
Related Issues
GUS work item: W-23385448