Skip to content

Grids: throw E1046 errow if key field was removed from data inside onAIColumnRequestCreating - #34510

Open
anna-shakhova wants to merge 2 commits into
DevExpress:mainfrom
anna-shakhova:ai_column_e1046_main
Open

Grids: throw E1046 errow if key field was removed from data inside onAIColumnRequestCreating#34510
anna-shakhova wants to merge 2 commits into
DevExpress:mainfrom
anna-shakhova:ai_column_e1046_main

Conversation

@anna-shakhova

Copy link
Copy Markdown
Contributor

No description provided.

@anna-shakhova anna-shakhova self-assigned this Jul 27, 2026
Copilot AI review requested due to automatic review settings July 27, 2026 14:57
@anna-shakhova
anna-shakhova requested a review from a team as a code owner July 27, 2026 14:57

Copilot AI 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.

Pull request overview

Adds a safeguard to AI Column request creation in Grid Core so that if onAIColumnRequestCreating mutates the dataset and removes the configured key field, the grid reports E1046 and skips sending the AI request. This fits into the grids AI column integration flow by preventing malformed datasets from reaching the AI integration layer.

Changes:

  • Added isKeyMissingInData helper to detect missing key values in onAIColumnRequestCreating output.
  • Added an early E1046 error path in AIColumnIntegrationController.sendRequestCore when the key field is missing after the handler runs.
  • Moved “API Handlers / onAIColumnRequestCreating” tests into a dedicated Jest test file and added coverage for the new E1046 scenario.

Reviewed changes

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

File Description
packages/devextreme/js/__internal/grids/grid_core/ai_column/utils.ts Adds isKeyMissingInData helper used to validate the key field in handler-mutated data.
packages/devextreme/js/__internal/grids/grid_core/ai_column/controllers/m_ai_column_integration_controller.ts Fires E1046 and aborts request sending when the key field is missing after onAIColumnRequestCreating.
packages/devextreme/js/__internal/grids/grid_core/ai_column/tests/ai_column.integration.test.ts Removes API handler tests from the integration suite (tests are relocated).
packages/devextreme/js/__internal/grids/grid_core/ai_column/tests/ai_column.api_handlers.test.ts New focused test suite for API handler behavior, including the E1046 regression scenario.

Comment thread packages/devextreme/js/__internal/grids/grid_core/ai_column/utils.ts Outdated
Copilot AI review requested due to automatic review settings July 28, 2026 08:12
@anna-shakhova
anna-shakhova force-pushed the ai_column_e1046_main branch from 81c1753 to f945ab4 Compare July 28, 2026 08:12

Copilot AI 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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

packages/devextreme/js/__internal/grids/grid_core/ai_column/utils.ts:47

  • isKeyMissingInData currently returns false for compound keys (keyField: string[]), so it will never detect missing key parts and the request may proceed with invalid key extraction. Also, checking keyField in item doesn’t catch cases where the key property exists but its value is undefined, which still leads to an undefined key (consistent with the existing E1046 check based on row.key === undefined). Consider validating key presence by value for both single and compound keys.
export const isKeyMissingInData = (
  data: UserData[],
  keyField: string | string[],
): boolean => {
  if (typeof keyField !== 'string') {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants