Skip to content

fix(github): parse any configured environment in -e flag#679

Draft
Kiran01bm wants to merge 2 commits into
mainfrom
kiran01bm/parse-arbitrary-apply-environment
Draft

fix(github): parse any configured environment in -e flag#679
Kiran01bm wants to merge 2 commits into
mainfrom
kiran01bm/parse-arbitrary-apply-environment

Conversation

@Kiran01bm

@Kiran01bm Kiran01bm commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

The PR-comment parser hard-coded the -e flag to only match staging or
production. Any other environment defined in allowed_environments /
environment_order (e.g. a qa or load stage) failed to parse, so
schemabot apply -e <env> was silently treated as "missing env" and
rejected. plan without -e already fans out to all configured
environments, so only apply/confirm-style commands were affected.

What

Widen environmentRegex to accept any environment token
(-e\s+([a-z0-9][a-z0-9_-]*)). The leading-alphanumeric requirement keeps
it from swallowing a following flag (e.g. -e --tenant). Unknown or
unowned environments still fail closed downstream via
IsEnvironmentAllowed, so widening the parser does not loosen any safety
gate.

Before / after

before:  -e staging | -e production          (only these two parse)
-e qa, -e load, ...  ->  missing env, command rejected
after:   -e <any configured env>  ->  parsed, then validated against
allowed_environments (unknown envs still fail closed)

The PR-comment parser hard-coded -e to staging|production, so apply
commands for other configured environments (e.g. qa, load) were dropped
as "missing env". Widen the flag to accept any environment name; unknown
values still fail closed against allowed_environments downstream.
Copilot AI review requested due to automatic review settings July 4, 2026 06:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes SchemaBot’s PR-comment command parsing so schemabot apply / apply-confirm can accept any configured environment name via -e <env>, instead of only parsing staging or production.

Changes:

  • Broaden environmentRegex to capture any environment token ([a-z0-9][a-z0-9_-]*) after -e.
  • Add parser tests proving apply -e qa and apply -e load are recognized.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pkg/webhook/commands.go Expands -e parsing to accept arbitrary environment tokens.
pkg/webhook/commands_test.go Adds tests covering custom environment parsing in -e.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/webhook/commands_test.go
Guard the leading-alphanumeric requirement in the environment regex so a
future loosening that lets -e swallow a following flag (e.g. --tenant)
is caught.
@Kiran01bm Kiran01bm marked this pull request as ready for review July 4, 2026 06:29
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@Kiran01bm Kiran01bm marked this pull request as draft July 4, 2026 06:32
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