Skip to content

feat: fix the 451 CoreConsole error into a better user flow to accept developer terms#262

Merged
dthampy merged 5 commits into
masterfrom
feat/dev-terms-acceptance
Jun 12, 2026
Merged

feat: fix the 451 CoreConsole error into a better user flow to accept developer terms#262
dthampy merged 5 commits into
masterfrom
feat/dev-terms-acceptance

Conversation

@dthampy

@dthampy dthampy commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Description

This PR handles the Developer Terms of Service acceptance flow before Console commands call terms-gated Developer Console APIs.
When the selected org has not accepted the current Developer Terms, interactive Console commands now show a CLI-native prompt and can accept the terms through the existing Console SDK methods.
Structured-output commands using --json or --yml fail fast with an actionable error instead of prompting, so scripts and CI consumers do not receive invalid JSON/YAML output.

Related Issue

#203

Motivation and Context

Users who had not accepted Developer Terms could see a raw 451 Console API error telling them to call the terms API manually. Hence the Console plugin needed to surface a helpful, user-facing flow for this specific terms-acceptance condition.
This mirrors the existing aio-cli-plugin-app approach for interactive usage while preserving machine-readable output for --json and --yml commands.

How Has This Been Tested?

npm test ( 100% unit test coverage maintained)

Manual testing steps

aio plugins link .

Screenshots (if appropriate):

Deeptys-MacBook-Pro-2:Downloads dthampy$ aio console project ls
Screenshot 2026-06-10 at 6 17 35 PM
Screenshot 2026-06-10 at 6 18 30 PM

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

github-actions[bot]
github-actions Bot previously approved these changes Jun 10, 2026

@github-actions github-actions Bot 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.

🤖 PR Reviewer

The implementation is clean, well-documented, and consistently applied across all relevant commands. The logic for gating prompts behind skipPrompts and the fast-fail path is correct. One minor issue: the template literal in the prompt message mixes a hardcoded newline with a \n escape and leading whitespace, producing inconsistent spacing in the rendered output.

LGTM! This PR looks good to merge.


💡 How to re-trigger

Comment /review or /pr-reviewer on this PR

this.error('The Developer Terms of Service were declined')
}
const accepted = await consoleCLI.acceptDevTermsForOrg(orgId)
if (!accepted) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The prompt string has a raw newline followed by \n and 4 spaces of indentation, which will render as an extra blank line with leading whitespace in the terminal. Flatten to a single consistent separator.

Suggested change
if (!accepted) {
const confirmDevTerms = await consoleCLI.prompt.promptConfirm(`${terms.text}\n\nYou have not accepted the Developer Terms of Service. Go to ${hyperlinker(DEV_TERMS_URL, DEV_TERMS_URL)} to view the terms. Do you accept the terms? (y/n):`)

@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions github-actions Bot 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.

🤖 PR Reviewer

The implementation is clean, well-tested, and consistently applied across all subcommands. The ensureDevTermAccepted method correctly handles the accept/decline/skip-prompts flows, and the test coverage is thorough. One previously raised issue about the prompt string formatting remains unaddressed.

🔄 1 re-raised suggestion(s) from previous review


💡 How to re-trigger

Comment /review or /pr-reviewer on this PR

}
const accepted = await consoleCLI.acceptDevTermsForOrg(orgId)
if (!accepted) {
this.error('The Developer Terms of Service could not be accepted')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[Re-raised] The prompt string contains a literal \n followed by \n (resulting in a double newline between terms text and the prompt message), which is intentional and fine, but the string also starts with ${terms.text} which may itself contain trailing newlines causing inconsistent terminal output. More critically, the raw \n in a template literal renders as a newline character which is correct — however the previous review flagged that the indentation of the source line (4 spaces before the closing backtick area) could cause leading whitespace. The real issue is the string is fine as-is for the newlines, but terms.text is user-controlled content from the API and is rendered directly into the terminal without any sanitization or length check, which could be a large wall of text overwhelming the prompt.

Suggested change
this.error('The Developer Terms of Service could not be accepted')
const termsText = terms.text ? terms.text.trim() : ''
const confirmDevTerms = await consoleCLI.prompt.promptConfirm(`${termsText}\n\nYou have not accepted the Developer Terms of Service. Go to ${hyperlinker(DEV_TERMS_URL, DEV_TERMS_URL)} to view the terms. Do you accept the terms? (y/n):`)

@github-actions github-actions Bot dismissed their stale review June 10, 2026 23:27

Superseded by new review

@github-actions github-actions Bot dismissed their stale review June 10, 2026 23:50

Superseded by new review

github-actions[bot]
github-actions Bot previously approved these changes Jun 10, 2026

@github-actions github-actions Bot 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.

🤖 PR Reviewer

The implementation is well-structured and the previous suggestion about terms.text sanitization has been partially addressed with trimEnd(). The hyperlinker dependency is properly added and the feature is consistently applied across all subcommands with good test coverage. One minor issue remains with the unsanitized terms.text content — trimEnd() was applied instead of the suggested trim(), which still allows leading whitespace/newlines from API-controlled content to appear in the terminal prompt.

LGTM! This PR looks good to merge.


💡 How to re-trigger

Comment /review or /pr-reviewer on this PR

this.error('The Developer Terms of Service were declined')
}
const accepted = await consoleCLI.acceptDevTermsForOrg(orgId)
if (!accepted) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[Re-raised] trimEnd() was applied (vs the suggested trim()), so leading whitespace or newlines in API-controlled terms.text could still produce unexpected terminal output. trim() would be safer here.

Suggested change
if (!accepted) {
const termsText = terms.text ? terms.text.trim() : ''

@github-actions github-actions Bot dismissed their stale review June 10, 2026 23:52

Superseded by new review

@github-actions github-actions Bot 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.

🤖 PR Reviewer

The implementation is clean and well-tested. The trimEnd() vs trim() issue from the previous review remains unaddressed — leading whitespace in API-controlled terms.text could produce unexpected terminal output. All other aspects of the change look solid: the guard is consistently applied across all subcommands, the skip-prompts path fails fast correctly, and the test coverage is comprehensive.

🔄 1 re-raised suggestion(s) from previous review


💡 How to re-trigger

Comment /review or /pr-reviewer on this PR

this.error('The Developer Terms of Service were declined')
}
const accepted = await consoleCLI.acceptDevTermsForOrg(orgId)
if (!accepted) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[Re-raised] trimEnd() was applied (vs the suggested trim()), so leading whitespace or newlines in API-controlled terms.text could still produce unexpected terminal output. trim() would be safer here.

Suggested change
if (!accepted) {
const termsText = terms.text ? terms.text.trim() : ''

@github-actions github-actions Bot dismissed their stale review June 10, 2026 23:58

Superseded by new review

@github-actions github-actions Bot 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.

🤖 PR Reviewer

The implementation is clean, well-tested, and correctly gates all console subcommands behind the developer terms check. The re-raised trim() vs trimEnd() issue has been resolved — trim() is now used. One minor remaining issue: hyperlinker(DEV_TERMS_URL, DEV_TERMS_URL) passes the same value as both the text and URL, making the hyperlinker call redundant (it would render as plain text in terminals that don't support hyperlinks, and as a hyperlink with the URL as its label in terminals that do — either way, just using the URL directly would be equivalent and simpler). This is cosmetic and not a blocker.

LGTM! This PR looks good to merge.


💡 How to re-trigger

Comment /review or /pr-reviewer on this PR

@sandeep-paliwal

Copy link
Copy Markdown
Contributor

Fix looks fine.
One concern about the code change, is it possible if we can move the ensureDevTermAccepted check to parent class and force it for all command execution? This way we wont repeat the call in all commands and will be future safe not to miss out on this call for any new commands added. WDYT @dthampy ?

@dthampy

dthampy commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

Fix looks fine. One concern about the code change, is it possible if we can move the ensureDevTermAccepted check to parent class and force it for all command execution? This way we wont repeat the call in all commands and will be future safe not to miss out on this call for any new commands added. WDYT @dthampy ?

I kept the check explicit per command because the parent class ConsoleCommand does not always have enough context to safely run this check
Some commands should not run this check. For example :

console:org:list / console:org:select  -> happens before or during org selection
console:open does not call the Console SDK APIs that's involved here
help/topic commands should not trigger auth/API calls
`--json / --yml `commands need fast-fail behavior, while regular commands can prompt

So if we force this check in the parent class, we risk adding extra auth/API calls to commands that do not need them thereby breaking org-selection flows or trigger prompts when the command doesn't know how to preserve the structured output

@dthampy dthampy merged commit 58fa13c into master Jun 12, 2026
11 checks passed
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.

3 participants