Skip to content

fix(environments): skip env:update when flags match the current settings - #296

Open
SakshiKoli-CS wants to merge 5 commits into
v2-devfrom
CL-8833
Open

SakshiKoli-CS wants to merge 5 commits into
v2-devfrom
CL-8833

Conversation

@SakshiKoli-CS

Copy link
Copy Markdown
Contributor

Jira: CL-8833

What

launch:env:update sent a PUT whenever any flag was passed, even when every value equalled the environment's current setting. It reported "✔ Environment updated successfully." and moved updatedAt. hasChanges() only checked that a flag was given; it never compared with the environment it had already read.

  • After reading the environment, the updater drops every flag whose value matches the current setting. Toggles and response mode are compared in their flag form (enable/disable, streaming/buffered).
  • If nothing is left, it prints "Environment not updated. No changes were entered.", exits 0 and sends nothing. No disable confirmation is asked for a setting that is already off.
  • --password-protection enable is always kept, because enabling it again rotates the credentials.
  • The interactive Response mode prompt defaults to the current mode when the API reports it.
  • toggleOf / responseModeOf now live in environment.inputs.ts, so the updater no longer imports runtime helpers from the prompt module.

Known limitation / follow-up: the REST GET environment response does not expose isStreamingEnabled yet (management-service REST DTO has no @Expose for it), so --res-mode is still always sent. The CLI compares it automatically once the API returns it.

Overlap: #295 (CL-8827) drops --description from the same files. Whichever merges second needs a small rebase (remove description from currentValuesOf and its tests).

Tests

  • Unit: unchanged flags for every setting send nothing; mixed changed/unchanged flags send only the changes; already-on password protection is still re-enabled; an unchanged --framework dropped while --server-cmd is checked against the current framework; response-mode prompt default.
  • Integration: all flags matching the fixture exit 0 with the no-changes line and no PUT.
  • npm test: 3883/3883 passed; tsc and eslint clean.

#claude_code#
🤖 Generated with Claude Code

…ings

launch:env:update sent a PUT whenever any flag was passed, even when every
value equalled what the environment already had: it reported success and
moved updatedAt. hasChanges() only checked that a flag was given and never
compared with the environment it had just read.

The updater now drops each flag whose value matches the current setting
(toggles and response mode compared in their flag form) before deciding;
with nothing left it prints "No changes were entered", exits 0 and sends
nothing, and asks no disable confirmation for a setting already off.
--password-protection enable is always kept, since re-enabling rotates the
credentials. The interactive response-mode prompt defaults to the current
mode when the API reports it.

The REST GET environment does not return isStreamingEnabled yet, so
--res-mode is still always sent until management-service exposes it.
.talismanrc checksums refreshed for the three edited files.

#claude_code#
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@SakshiKoli-CS
SakshiKoli-CS requested review from a team as code owners November 19, 2026 07:13
@snyk-io

snyk-io Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 2 25 ✅ Passed
🟡 Medium Severity 0 1 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

ℹ️ Vulnerabilities Without Available Fixes (Informational Only)

The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:

  • Critical without fixes: 0
  • High without fixes: 2
  • Medium without fixes: 1
  • Low without fixes: 0

✅ BUILD PASSED - All security checks passed

@dhruv-parekh-cs dhruv-parekh-cs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed the whole PR: 0 high, 0 medium, 2 low (inline). Neither blocks approval.

— 🤖 launch-pr-review-agent (Claude)


Generated by Claude Code

Comment thread src/environments/environment.update.ts Resolved
Comment thread src/environments/environment.update.ts Resolved
SakshiKoli-CS and others added 2 commits November 19, 2026 16:10
Brings in #295, which removed the environment description from env:create,
env:update and env:get. The unchanged-value filter no longer compares a
description, and its test case drops the description flag. Refreshes the
talisman checksum of environment.update.test.ts and the generated README.

#claude_code#
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
The v2-dev merge changed files that already have reviewed .talismanrc
entries (CL-8827's env:create/update/get and failure files, plus this
fix's environment files). Only their checksums are refreshed; no new
entries or detectors are added.

#claude_code#
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 2 25 ✅ Passed
🟡 Medium Severity 0 1 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

ℹ️ Vulnerabilities Without Available Fixes (Informational Only)

The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:

  • Critical without fixes: 0
  • High without fixes: 2
  • Medium without fixes: 1
  • Low without fixes: 0

✅ BUILD PASSED - All security checks passed

- toggleOf and responseModeOf treat null like undefined, so a setting the
  API reports as null no longer drops the user's flag; null cases added
  for cache priming, auto deploy, cs-auth and response mode.
- Remove the code comment on currentValuesOf (AGENTS.md: no code
  comments); the rotation test already pins that behaviour.

#claude_code#
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

@dhruv-parekh-cs dhruv-parekh-cs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-review since 8dc67c6 (merge of v2-dev after CL-8827, talisman refresh): 0 high, 0 medium, 0 low new.

Still open from the earlier review (both low, neither blocks approval):

  • Low src/environments/environment.update.ts:91: toggleOf/responseModeOf check only === undefined, so a null from the API still counts as a known current value.
  • Low src/environments/environment.update.ts:82: the code comment AGENTS.md forbids is still there.

— 🤖 launch-pr-review-agent (Claude)


Generated by Claude Code

@SakshiKoli-CS

Copy link
Copy Markdown
Contributor Author

/ship 2b summary — Fixed: null treated as an unknown current value (+ null test cases); removed the code comment on currentValuesOf (both in 81ed2c2). Resolved: both launch-pr-review-agent threads. Left for human: none. General comments: Snyk and GitHub Actions scan-status posts only (no action requested). Also merged v2-dev after #295 (CL-8827) dropped --description and refreshed the affected talisman checksums. Next: needs a human approval to merge.

@github-actions

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 2 25 ✅ Passed
🟡 Medium Severity 0 1 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

ℹ️ Vulnerabilities Without Available Fixes (Informational Only)

The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:

  • Critical without fixes: 0
  • High without fixes: 2
  • Medium without fixes: 1
  • Low without fixes: 0

✅ BUILD PASSED - All security checks passed

@dhruv-parekh-cs dhruv-parekh-cs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-review since a907f11 (null is not a known current value): 0 high, 0 medium, 1 low (inline).

Both lows from the earlier review are fixed at this head: toggleOf/responseModeOf now treat null as unknown, and the code comment is gone. 1 low open in total, so this doesn't block approval.

— 🤖 launch-pr-review-agent (Claude)


Generated by Claude Code

Comment thread src/environments/environment.inputs.ts Resolved
const kept = { ...request };

for (const field of Object.keys(current) as (keyof EnvironmentChanges)[]) {
if (current[field] !== undefined && kept[field] === current[field]) {

@tejas-contentstack tejas-contentstack Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit (optional): users can no longer re-apply a setting to re-run what the server does when it is set. Only --password-protection enable is exempt from this filter. But management-service also emits a background job when isContentstackAuthenticationEnabled is written (updateContentstackAuthentication in environment.service.ts), and it re-runs the cache-priming handler when isCachePrimingEnabled is written. So --cs-auth enable on an environment that already reports it as enabled was a way to re-push edge/KV config after drift. It now prints "No changes were entered" and sends nothing.

Fix: confirm with the service owners that re-sending these toggles has no side effect anyone relies on. If it does, exempt csAuth: 'enable' the same way passwordProtection: 'enable' is exempted.

— 🤖 Claude review (Opus 5.5, high effort)


Generated by Claude Code

Comment thread src/environments/types.ts Resolved

@tejas-contentstack tejas-contentstack left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

High-effort review found 6 findings, so this isn't an approval. 1 is a bug that was already there before this PR: the interactive Response mode prompt defaults to buffered while isStreamingEnabled is unknown. The other 5 are nits: re-applying --cs-auth/--cache-priming is now skipped, passwordProtection can be absent from the response, the Environment type doesn't allow the null values the code now handles, the no-changes message doesn't say which flags were skipped, and an unchanged --server-cmd now skips the framework check. None of them blocks the PR. Details are in the inline comments. All checks pass, and the PR is not a draft.

— 🤖 Claude review (Opus 5.5, high effort), requested by tejas


Generated by Claude Code

…n Environment

- When flags were passed and every one matches the current settings,
  env:update now prints "Environment not updated: --cs-auth, --cache-priming
  already match the current settings." instead of "No changes were
  entered"; the interactive checklist keeps the old line.
- Environment declares the toggles and isStreamingEnabled as boolean | null
  and serverCommand as string | null, matching the wire. The compiler then
  surfaced env:get showing "disabled" for a null toggle; it now shows "-".

#claude_code#
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

@dhruv-parekh-cs dhruv-parekh-cs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-review since 81ed2c2 (name matching flags, allow null in Environment): 0 high, 0 medium, 0 low new.

Still open from an earlier review (low, doesn't block approval; left as is by decision with the author):

  • Low src/environments/environment.inputs.ts:36 / environment.update.prompt.ts:180: the interactive toggle prompt has no default when the API reports null, and the prompt test has no null case.

1 low open in total, so this is approved.

— 🤖 launch-pr-review-agent (Claude)


Generated by Claude Code

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.

4 participants