Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/config/__tests__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ describe('Configuration System', () => {
result.warnings.some(warning => warning.includes('placeholder'))
).toBe(true)
})

it('should fail validation with GITHUB_ prefix in variable names', () => {
process.env.GITHUB_SECRET = 'some-secret-value'

const result = validateConfiguration()
expect(result.success).toBe(false)
expect(
result.errors.some(error =>
error.includes('Secret names must not start with GITHUB_')
)
).toBe(true)
})
})

describe('Environment-Specific Configuration', () => {
Expand Down
10 changes: 10 additions & 0 deletions lib/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,16 @@ export type StagingEnvConfig = z.infer<typeof stagingEnvSchema>
export function validateEnv(): EnvConfig {
const env = process.env

// Check for reserved GITHUB_ prefix in environment variable names
const githubPrefixedVars = Object.keys(env).filter(key => key.startsWith('GITHUB_'))
if (githubPrefixedVars.length > 0) {
throw new Error(
`Environment validation failed:\nSecret names must not start with GITHUB_ as this prefix is reserved by GitHub.\n` +
`Found variables: ${githubPrefixedVars.join(', ')}\n\n` +
`Please rename these variables to use a different prefix.`
)
}

// Choose schema based on environment (use APP_ENV for staging detection)
const appEnv = env.APP_ENV || env.NODE_ENV
let schema: z.ZodSchema
Expand Down
Loading
Loading