Skip to content

Improve ModelSyntaxError validation#1579

Merged
Magssch merged 7 commits intomainfrom
fix-modelsyntax-errors
Feb 27, 2026
Merged

Improve ModelSyntaxError validation#1579
Magssch merged 7 commits intomainfrom
fix-modelsyntax-errors

Conversation

@Magssch
Copy link
Copy Markdown
Contributor

@Magssch Magssch commented Feb 26, 2026

Description

Improve validation error messages for data model imports, especially for enum properties. Previously, unhandled enum validation errors raised a RuntimeError with the unhelpful message "This is a neat bug, report to the team" which swallowed all diagnostic context. Now all enum validation paths return descriptive messages, view property identifier errors point to the correct table/row, and the union tag error handler uses structured Pydantic context instead of fragile string parsing.

Examples of improved errors:

1. Enum validation errors (was RuntimeError, now descriptive)

Before:

Read Physical Data Model - excel ❌
This is a neat bug, report to the team.

After:

In table 'Properties' row 11 column 'Value Type' -> enum: collection has too many possible values (max 32 allowed).

In table 'Properties' row 12 column 'Value Type' -> enum: Enum values 'x:auto', 'x:cut', 'x:total' do not match the required pattern: ^[_A-Za-z][_0-9A-Za-z]{0,127}$

2. Enum validator messages (grouped instead of repeated per key)

Before:

Enum value 'x:auto' is not valid. Enum values must match the pattern: ...;Enum value 'x:cut' is not valid. Enum values must match the pattern: ...;Enum value 'x:total' is not valid. Enum values must match the pattern: ...

After:

Enum values 'x:auto', 'x:cut', 'x:total' do not match the required pattern: ^[_A-Za-z][_0-9A-Za-z]{0,127}$

3. Invalid union tag errors (no internal discriminator details)

Before:

Input value 'http' found using 'index_type' | 'indexType' does not match any of the expected values: 'btree', 'inverted'.

After:

Input value 'http' does not match any of the expected values: 'btree', 'inverted'.

Bump

  • Patch
  • Skip

Changelog

Improved

  • Improve error messages when importing data models with invalid enum properties (too many values, invalid value names, missing collection references)
  • Fix misleading error locations that pointed to the 'Views' table when the issue needed to be fixed in the 'Properties' table
  • Improve error message formatting for invalid value types and index types

@Magssch Magssch requested a review from a team as a code owner February 26, 2026 14:19
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

@Magssch
Copy link
Copy Markdown
Contributor Author

Magssch commented Feb 26, 2026

/gemini review

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 26, 2026

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
7289 6732 92% 90% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
cognite/neat/_data_model/models/dms/_constants.py 100% 🟢
cognite/neat/_data_model/models/dms/_data_types.py 93% 🟢
cognite/neat/_utils/validation.py 85% 🟢
TOTAL 93% 🟢

updated for commit: 15f6a63 by action🐍

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request significantly improves the validation error messages for data model imports, particularly for enum properties and view property identifiers. The changes replace generic runtime errors with descriptive messages, making it much easier to diagnose and fix issues. The refactoring of enum validation logic to collect and report multiple error types, and the use of structured Pydantic context for union tag errors, enhance the robustness and clarity of the validation process. Additionally, the introduction of a constant for maximum enum values and pre-compilation of regex patterns contribute to better maintainability and efficiency.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 26, 2026

Codecov Report

❌ Patch coverage is 60.00000% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.80%. Comparing base (636b9b5) to head (15f6a63).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cognite/neat/_utils/validation.py 50.00% 8 Missing ⚠️
cognite/neat/_data_model/models/dms/_data_types.py 66.66% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1579      +/-   ##
==========================================
- Coverage   91.90%   91.80%   -0.11%     
==========================================
  Files         126      126              
  Lines        7404     7427      +23     
==========================================
+ Hits         6805     6818      +13     
- Misses        599      609      +10     
Files with missing lines Coverage Δ
cognite/neat/_data_model/models/dms/_constants.py 100.00% <100.00%> (ø)
cognite/neat/_data_model/models/dms/_data_types.py 92.94% <66.66%> (-4.32%) ⬇️
cognite/neat/_utils/validation.py 83.75% <50.00%> (-6.25%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@doctrino doctrino left a comment

Choose a reason for hiding this comment

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

Nice improvements to the dealing with enums. See the one comment, I am confused by the extra checks inside the reader.

@doctrino doctrino self-requested a review February 27, 2026 10:48
@Magssch Magssch merged commit 3be0ec6 into main Feb 27, 2026
10 checks passed
@Magssch Magssch deleted the fix-modelsyntax-errors branch February 27, 2026 11:34
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