Skip to content

feat: log warning for Gen 1-only operations - #2290

Merged
veronika-alraheem merged 1 commit into
mainfrom
1318-gen1-warnings
Nov 26, 2026
Merged

veronika-alraheem merged 1 commit into
mainfrom
1318-gen1-warnings

Conversation

@veronika-alraheem

@veronika-alraheem veronika-alraheem commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

PR summary

Emit a log warning for operations only available for Gen 1.
Fixes i1318

PR Checklist

Please make sure that your PR fulfills the following requirements:

  • The commit message follows the
    Angular Commit Message Guidelines.
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • New tests
  • Build/CI related changes
  • Documentation content changes
  • Other (please describe)

What is the current behavior?

Calls to Gen 1-only operations execute without any user-facing warning that they are unavailable for Gen 2.

What is the new behavior?

CloudantBaseService.createRequest checks the request URL against ^/_api/v2(/|$). On a match it logs:

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@veronika-alraheem
veronika-alraheem marked this pull request as draft November 19, 2026 14:26
@veronika-alraheem
veronika-alraheem marked this pull request as ready for review November 19, 2026 19:40
@veronika-alraheem veronika-alraheem changed the title feat: log warning via request interceptor for Gen 1-only operations feat: log warning for Gen 1-only operations Nov 19, 2026

@ricellis ricellis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, one thing and some nits

Comment thread lib/cloudantBaseService.ts Outdated
logger.warn(message);
if (isGen1ErrorEnabled()) {
const err = new UnsupportedOperationError(message);
err.code = 'ERR_UNSUPPORTED_OPERATION';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For our other validation rules based we used ERR_INVALID_ARG_VALUE that is a Node.js error code that happened to be correct for what we were checking, an invalid arg value.
For this new validation there doesn't appear to be a native code that would work, so I'm a little concerned about using a made up code that looks like a Node.js one (not least because they might use it later for something slightly different). We should probably just use our own code e.g.

Suggested change
err.code = 'ERR_UNSUPPORTED_OPERATION';
err.code = 'CLOUDANT_SDK_UNSUPPORTED_OPERATION';

Comment thread test/unit/cloudantBaseService.test.js Outdated
it(`Throws for ${operationId} when errors are enabled`, async () => {
process.env[gen1ErrorsVar] = 'true';
await assert.rejects(service.createRequest(params(operationId)), {
code: 'ERR_UNSUPPORTED_OPERATION',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Will need an update to match

Comment thread test/unit/cloudantBaseService.test.js Outdated
process.env[gen1ErrorsVar] = 'TRUE';
await assert.rejects(
service.createRequest(params('getCorsInformation')),
{ code: 'ERR_UNSUPPORTED_OPERATION' }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Will need an update to match

Comment thread lib/cloudantBaseService.ts Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copyright update

Comment thread test/unit/cloudantBaseService.test.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copyright update

@veronika-alraheem
veronika-alraheem merged commit e5d9805 into main Nov 26, 2026
8 checks passed
@veronika-alraheem
veronika-alraheem deleted the 1318-gen1-warnings branch November 26, 2026 18:16
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