Describe the Bug
In our current project we have the situation that we must use GCP buckets with a prefix when deploying to the cloud but at the same time we cannot use (or access) them when developing locally - due to company security restrictions.
Because of this the enabled property of the GCP storage adapter set to enabled = false locally and enabled = true when running in GCP.
The problem, now, is that generate:types will generate different output depending on the enabled state, since we have to use a prefix. When the GCP plugin is disabled the generated media type will not contain the prefix attribute. And if the plugin is enabled the generated media type then will have the additional prefix attribute.
This also has an effect on migrations. Because when enabled the system will add a migration for adding the prefix column. And if disabled the system might add a migration for removing the column.
This makes it really, really difficult to maintain, because if the developer is not careful generate:types & migrations might break our GCP setup.
Link to the code that reproduces this issue
https://github.com/woeye/storage-adapter-issue
Reproduction Steps
Configure the GCP storage adapter plugin for a collection, like so:
let enableBucket = false
if (process.env.GCP_BUCKET_NAME) {
enableBucket = true
}
export default buildConfig({
admin: {
user: Users.slug,
importMap: {
baseDir: path.resolve(dirname),
},
},
...
plugins: [
payloadCloudPlugin(),
gcsStorage({
enabled: enableBucket,
collections: {
media: {
prefix: 'media',
},
},
bucket: process.env.GCP_BUCKET_NAME || '', // '' is ok if the plugin is disabled
options: {},
}),
],
})
Make sure ENV variable GCP_VIDEO_BUCKET_NAME is not set. Then run generate:types. The media interface will not contain the prefix variable.
Then make sure GCP_VIDEO_BUCKET_NAME is set, for example by adding it to .env:
GCP_BUCKET_NAME=gcp-sample-bucket
Run generate:types again. Now the media interface does have a prefix attribute.
This will also impact migrate:create.
Which area(s) are affected? (Select all that apply)
db-postgres, plugin: cloud-storage
Environment Info
Binaries:
Node: 24.6.0
npm: 11.5.1
Yarn: N/A
pnpm: 10.13.1
Relevant Packages:
payload: 3.49.1
next: 15.4.6
@payloadcms/db-mongodb: 3.49.1
@payloadcms/db-postgres: 3.49.1
@payloadcms/email-nodemailer: 3.49.1
@payloadcms/graphql: 3.49.1
@payloadcms/live-preview: 3.49.1
@payloadcms/live-preview-react: 3.49.1
@payloadcms/next/utilities: 3.49.1
@payloadcms/payload-cloud: 3.49.1
@payloadcms/plugin-cloud-storage: 3.49.1
@payloadcms/plugin-nested-docs: 3.49.1
@payloadcms/plugin-seo: 3.49.1
@payloadcms/richtext-lexical: 3.49.1
@payloadcms/storage-gcs: 3.49.1
@payloadcms/translations: 3.49.1
@payloadcms/ui/shared: 3.49.1
react: 19.1.1
react-dom: 19.1.1
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:40 PDT 2025;
Describe the Bug
In our current project we have the situation that we must use GCP buckets with a prefix when deploying to the cloud but at the same time we cannot use (or access) them when developing locally - due to company security restrictions.
Because of this the
enabledproperty of the GCP storage adapter set toenabled = falselocally andenabled = truewhen running in GCP.The problem, now, is that
generate:typeswill generate different output depending on theenabledstate, since we have to use a prefix. When the GCP plugin is disabled the generated media type will not contain the prefix attribute. And if the plugin is enabled the generated media type then will have the additional prefix attribute.This also has an effect on migrations. Because when enabled the system will add a migration for adding the prefix column. And if disabled the system might add a migration for removing the column.
This makes it really, really difficult to maintain, because if the developer is not careful
generate:types& migrations might break our GCP setup.Link to the code that reproduces this issue
https://github.com/woeye/storage-adapter-issue
Reproduction Steps
Configure the GCP storage adapter plugin for a collection, like so:
Make sure ENV variable GCP_VIDEO_BUCKET_NAME is not set. Then run
generate:types. The media interface will not contain the prefix variable.Then make sure GCP_VIDEO_BUCKET_NAME is set, for example by adding it to
.env:Run
generate:typesagain. Now the media interface does have a prefix attribute.This will also impact
migrate:create.Which area(s) are affected? (Select all that apply)
db-postgres, plugin: cloud-storage
Environment Info