Skip to content

Fixes #37516: Reject tag recognizers saved without a supported language - #37517

Merged
ayush-shah merged 4 commits into
mainfrom
ayush-shah/recognizer-require-language
Nov 11, 2026
Merged

ayush-shah merged 4 commits into
mainfrom
ayush-shah/recognizer-require-language

Conversation

@ayush-shah

Copy link
Copy Markdown
Member

Describe your changes:

Fixes #37516

The server now rejects a tag recognizer that the ingestion client cannot parse because of its language. Every recognizer type except predefined must set recognizerConfig.supportedLanguage to a valid ClassificationLanguage. A predefined recognizer may leave it out, but if it sets one, the value must be valid. A violation returns 400 naming the recognizer.

Why: recognizerConfig is an untyped Object on the server, so a config without supportedLanguage was stored as-is. The ingestion client's generated model requires the field, so it could not parse that tag. Auto-classification then skipped the tag; on 2.0.x it dropped the whole classification. The run still reported success.

Where it runs:

  • Create (POST, bulk, PUT-create): every recognizer is checked in prepare.
  • Update (PATCH, PUT-update, CSV import, recognizer-feedback apply): TagUpdater checks only recognizers whose config is new or edited. A tag stored before this rule therefore stays editable, including when recognizer feedback patches the whole tag. Configs are matched by value, not id, because a PUT may resend recognizers without their ids.

Type of change:

  • Bug fix

High-level design:

N/A — small change.

Tests:

Use cases covered

  • POST a tag whose pattern recognizer has no supportedLanguage → 400.
  • PATCH that removes supportedLanguage from an existing pattern recognizer → 400, and the stored value is unchanged.
  • A tag stored without supportedLanguage (written through the DAO) can still be edited: a PATCH of its description → 200, and a PUT resending its recognizers without ids → 200.
  • An unknown language ("english") is rejected for pattern and for predefined recognizers. A predefined recognizer without a language, and a pattern recognizer with any, are accepted.

Unit tests

  • I added unit tests for the new/changed logic.
  • Files added/updated: openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/TagRepositoryUnitTest.java
  • mvn -pl openmetadata-service test -Dtest=TagRepositoryUnitTest: 24 run, 0 failures (at e012339af1).

Backend integration tests

  • I added integration tests in openmetadata-integration-tests/ for new/changed API endpoints.
  • Files added/updated: openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/TagResourceIT.java: post_recognizerWithoutSupportedLanguage_rejected, patch_recognizerWithoutSupportedLanguage_rejected, patch_tagStoredWithoutSupportedLanguage_staysEditable, put_tagStoredWithoutSupportedLanguage_resentWithoutIds_accepted.
  • Not run locally. Docker was unavailable on the author's machine. The ITs compile at e012339af1 (mvn -pl openmetadata-integration-tests test-compile). The focused plan (make java_affected ARGS="--scope focused") selects TagRepositoryUnitTest and TagResourceIT (mysql-elasticsearch, parallel). TagResourceIT is pending and runs in the merge queue.

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

Not performed beyond the tests above. The failure was diagnosed on a 2.0.7 deployment: one pattern recognizer had been saved without supportedLanguage, the pipeline logged Failed to fetch tags for classification Sensitivity: 22 validation errors for Tag, and no column was tagged.

UI screen recording:

Not applicable — backend-only validation change.

Checklist:

  • I have read the CONTRIBUTING document.

  • My PR title is Fixes <issue-number>: <short explanation>

  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.

  • I have commented on my code, particularly in hard-to-understand areas.

  • For JSON Schema changes: not applicable, no schema change. supportedLanguage is already required in the recognizer schemas.

  • For a UI feature or feature task: not applicable, backend only.

  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

  • Self-review: I reviewed the final diff against REVIEW.md (the pr-checklist skill runs it) and fixed every 🔴 finding, or answered it on the line below.

    • Three passes: e30264a882 (pre-amend 09bcb73692), 8e48e6baff, 9ecb0ee36c. The one 🔴, that a tag stored without a language became uneditable, is fixed in 8e48e6baff.
    • Fixed 🟡:
      • Predefined value check and create/PUT ITs, in 9ecb0ee36c.
      • The ITs assert the error message, and a unit case covers an explicit null predefined language, in e012339af1 (test-only).
    • Deferred 🟡, out of scope here:
      • Validating the rest of recognizerConfig (regexFlags, unknown keys) against its schema. The stored configs carry score as a string, so full validation needs its own change.
      • Backfilling tags already stored without a language. Choosing en or any is a separate decision.
      • Making the language field required in the Collate recognizer form, as an openmetadata-collate follow-up.
  • Decision check: no record needed. The schema already requires the field, and the update-only-changed-configs rule is stated in the code comment at TagUpdater.validateChangedRecognizers.

  • Bug fix: I have added a test that covers the exact scenario we are fixing.

The ingestion client's Tag model requires recognizerConfig.supportedLanguage
for every recognizer type but predefined. The server accepted a recognizer
without it, and the client then dropped every tag of that classification from
auto-classification while the run still reported success.
A tag stored with a language-less recognizer before the rule must stay
editable, including by recognizer feedback that patches the whole tag. Also
reject an unknown language value, which the ingestion client skips the same
way.
A predefined recognizer may omit supportedLanguage, but an unknown value is
still skipped by the ingestion client. Adds ITs for POST rejecting a recognizer
without a language and for a PUT resending stored recognizers without ids.
@ayush-shah
ayush-shah requested a review from a team as a code owner November 11, 2026 05:24
@ayush-shah
ayush-shah requested review from manerow and a balanced review from Copilot November 11, 2026 05:24
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

Comment on lines +246 to +260
/**
* The ingestion client's Tag model requires a valid supportedLanguage on every recognizer type
* but predefined, where it may be omitted; a tag it cannot parse is skipped by
* auto-classification while the run passes.
*/
static void validateSupportedLanguage(Recognizer recognizer) {
JsonNode config = JsonUtils.valueToTree(recognizer.getRecognizerConfig());
JsonNode language = config.path(SUPPORTED_LANGUAGE);
boolean languageOmitted =
PREDEFINED_RECOGNIZER_TYPE.equals(config.path("type").asText())
&& (language.isMissingNode() || language.isNull());
boolean languageValid =
Arrays.stream(ClassificationLanguage.values())
.anyMatch(l -> l.value().equals(language.asText()));
if (!languageOmitted && !languageValid) {

@gitar-bot gitar-bot Bot Nov 11, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Quality: Recognizer language rule is a client contract with no decision record

This PR adds a validation rule that the server and the ingestion client's Tag model must both follow, and the rule appears only in the PR description. Nothing in docs/decisions/ mentions supportedLanguage or tag recognizer validation. The repository squash-merges, so the description will not reach git log.

The record should state two things:

  1. The contract: every recognizer type except predefined must set recognizerConfig.supportedLanguage to a ClassificationLanguage value. A predefined recognizer may omit it, but any value it does set must be valid. This comes from the description: "Every recognizer type except predefined must set recognizerConfig.supportedLanguage to a valid ClassificationLanguage."
  2. The grandfathering rule: "On update, only recognizer configs that are new or edited are checked … Configs are matched by value rather than id, because a PUT may resend recognizers without their ids."

The Collate recognizer form follow-up and any future ingestion-side change depend on this rule, and only the record would keep it in the tree. Fix: add a dated record under docs/decisions/ and cite it as ADR:<date>-<slug> from validateSupportedLanguage and validateChangedRecognizers.

Record both rules and cite the record from TagRepository.:

# docs/decisions/2026-11-<dd>-tag-recognizers-require-a-supported-language.md
Status: Accepted

Every recognizer type except `predefined` sets `recognizerConfig.supportedLanguage`
to a `ClassificationLanguage` value; a `predefined` recognizer may omit it but, if set,
it must be valid. On update only new or edited recognizer configs, matched by value
not id, are checked, so tags stored before this rule stay editable.

Was this helpful? React with 👍 / 👎

@gitar-bot

gitar-bot Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Code Review ⚠️ Changes requested 🟡 Medium risk 0 closed / 1 findings

Validating recognizer languages on tag creation and edits could reject configurations callers previously saved, though unchanged legacy configs remain editable.

Adds server-side validation rejecting tag recognizers without a valid supportedLanguage (predefined may omit it), checked on create and on new or edited configs during update so legacy tags stay editable. Changes requested: the validation rule is a client contract currently documented only in the PR description, so add a dated decision record under docs/decisions/ and reference it from validateSupportedLanguage and validateChangedRecognizers.

⚠️ Quality: Recognizer language rule is a client contract with no decision record

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TagRepository.java:246-260 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TagRepository.java:817-828

This PR adds a validation rule that the server and the ingestion client's Tag model must both follow, and the rule appears only in the PR description. Nothing in docs/decisions/ mentions supportedLanguage or tag recognizer validation. The repository squash-merges, so the description will not reach git log.

The record should state two things:

  1. The contract: every recognizer type except predefined must set recognizerConfig.supportedLanguage to a ClassificationLanguage value. A predefined recognizer may omit it, but any value it does set must be valid. This comes from the description: "Every recognizer type except predefined must set recognizerConfig.supportedLanguage to a valid ClassificationLanguage."
  2. The grandfathering rule: "On update, only recognizer configs that are new or edited are checked … Configs are matched by value rather than id, because a PUT may resend recognizers without their ids."

The Collate recognizer form follow-up and any future ingestion-side change depend on this rule, and only the record would keep it in the tree. Fix: add a dated record under docs/decisions/ and cite it as ADR:<date>-<slug> from validateSupportedLanguage and validateChangedRecognizers.

Record both rules and cite the record from TagRepository.
# docs/decisions/2026-11-<dd>-tag-recognizers-require-a-supported-language.md
Status: Accepted

Every recognizer type except `predefined` sets `recognizerConfig.supportedLanguage`
to a `ClassificationLanguage` value; a `predefined` recognizer may omit it but, if set,
it must be valid. On update only new or edited recognizer configs, matched by value
not id, are checked, so tags stored before this rule stay editable.
🤖 Prompt for agents
Code Review: Adds server-side validation rejecting tag recognizers without a valid `supportedLanguage` (predefined may omit it), checked on create and on new or edited configs during update so legacy tags stay editable. Changes requested: the validation rule is a client contract currently documented only in the PR description, so add a dated decision record under `docs/decisions/` and reference it from `validateSupportedLanguage` and `validateChangedRecognizers`.

1. ⚠️ Quality: Recognizer language rule is a client contract with no decision record
   Files: openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TagRepository.java:246-260, openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TagRepository.java:817-828

   This PR adds a validation rule that the server and the ingestion client's Tag model must both follow, and the rule appears only in the PR description. Nothing in `docs/decisions/` mentions `supportedLanguage` or tag recognizer validation. The repository squash-merges, so the description will not reach `git log`.
   
   The record should state two things:
   
   1. **The contract:** every recognizer type except `predefined` must set `recognizerConfig.supportedLanguage` to a `ClassificationLanguage` value. A `predefined` recognizer may omit it, but any value it does set must be valid. This comes from the description: "Every recognizer type except predefined must set recognizerConfig.supportedLanguage to a valid ClassificationLanguage."
   2. **The grandfathering rule:** "On update, only recognizer configs that are new or edited are checked … Configs are matched by value rather than id, because a PUT may resend recognizers without their ids."
   
   The Collate recognizer form follow-up and any future ingestion-side change depend on this rule, and only the record would keep it in the tree. Fix: add a dated record under `docs/decisions/` and cite it as `ADR:<date>-<slug>` from `validateSupportedLanguage` and `validateChangedRecognizers`.

   Fix (Record both rules and cite the record from TagRepository.):
   # docs/decisions/2026-11-<dd>-tag-recognizers-require-a-supported-language.md
   Status: Accepted
   
   Every recognizer type except `predefined` sets `recognizerConfig.supportedLanguage`
   to a `ClassificationLanguage` value; a `predefined` recognizer may omit it but, if set,
   it must be valid. On update only new or edited recognizer configs, matched by value
   not id, are checked, so tags stored before this rule stay editable.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@ayush-shah ayush-shah added the To release Will cherry-pick this PR into the release branch label Nov 11, 2026
@ayush-shah
ayush-shah merged commit 93ec4e2 into main Nov 11, 2026
63 of 64 checks passed
@ayush-shah
ayush-shah deleted the ayush-shah/recognizer-require-language branch November 11, 2026 11:28
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Backport to 2.0 is under way. It is built from openmetadata-collate, which holds the credentials needed to open a PR here, and it will comment again with the result — nothing is needed from you unless it reports otherwise.

@gh-bot-collate

Copy link
Copy Markdown

🤖 Backport to 2.0 opened as #37568. Claude resolved a cherry-pick conflict to build it. It merges itself once the checks pass, so read the diff now if this change is a sensitive one.

gh-bot-collate Bot added a commit that referenced this pull request Nov 13, 2026
…ge (#37517) (#37568)

* Reject tag recognizers saved without supportedLanguage

The ingestion client's Tag model requires recognizerConfig.supportedLanguage
for every recognizer type but predefined. The server accepted a recognizer
without it, and the client then dropped every tag of that classification from
auto-classification while the run still reported success.

* Check recognizer language only on new or edited configs

A tag stored with a language-less recognizer before the rule must stay
editable, including by recognizer feedback that patches the whole tag. Also
reject an unknown language value, which the ingestion client skips the same
way.

* Check a predefined recognizer's language when set; cover create and PUT

A predefined recognizer may omit supportedLanguage, but an unknown value is
still skipped by the ingestion client. Adds ITs for POST rejecting a recognizer
without a language and for a PUT resending stored recognizers without ids.

* Assert the language error and cover an explicit null predefined language

(cherry picked from commit 93ec4e2)

Co-authored-by: Ayush Shah <ayush02shah12@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

To release Will cherry-pick this PR into the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Server accepts a tag recognizer without supportedLanguage, which auto-classification then silently skips

3 participants