Skip to content

#8137 - System should not add monomer to the library of wrong type field is provided#10035

Closed
oguzhanduran wants to merge 3 commits into
masterfrom
9137-system-shoulnot-add-monomer-to-the-library-with-wrong-type
Closed

#8137 - System should not add monomer to the library of wrong type field is provided#10035
oguzhanduran wants to merge 3 commits into
masterfrom
9137-system-shoulnot-add-monomer-to-the-library-with-wrong-type

Conversation

@oguzhanduran
Copy link
Copy Markdown
Collaborator

… issue

How the feature works? / How did you fix the issue?

(Screenshots, videos, or GIFs, if applicable)

Check list

  • unit-tests written
  • e2e-tests written
  • documentation updated
  • PR name follows the pattern #1234 – issue name
  • branch name doesn't contain '#'
  • PR is linked with the issue
  • base branch (master or release/xx) is correct
  • task status changed to "Code review"
  • reviewers are notified about the pull request

Comment thread packages/ketcher-core/src/application/ketcher.ts Fixed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds validation for monomer library updates provided in SDF format to prevent entries with missing/unknown > <type> from being converted/loaded, avoiding incorrect monomer types being added to the library.

Changes:

  • Introduces an allowlist for valid SDF > <type> values (based on KetTemplateType).
  • Filters out invalid SDF records and logs an error per rejected entry.
  • Applies this filtering to both updateMonomersLibrary and replaceMonomersLibrary flows before format conversions.

Comment on lines +817 to +818
* Validates SDF entries against allowed `> <type>` values before Indigo conversion.
* - No `> <type>` field at all → allowed (Indigo defaults to monomerTemplate)
Copy link
Copy Markdown
Collaborator Author

@oguzhanduran oguzhanduran May 14, 2026

Choose a reason for hiding this comment

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

Before Indigo conversion" — filterInvalidSdfEntries is called in filterSdfIfNeeded, which runs before ensureMonomersLibraryDataInKetFormat. That method calls this.structService.convert() for SDF input, and structService is the Indigo service. So the validation does happen before Indigo conversion.

"Indigo defaults to monomerTemplate" — This describes actual Indigo behavior: when no > field is present in an SDF entry, Indigo treats it as monomerTemplate during conversion. This context is important for maintainers to understand why we allow entries without a > field.

No changes needed here. @copilot

@AlexeyGirin AlexeyGirin changed the title 9137:fix system should not add monomer to the library with wrong type… #8137 - System should not add monomer to the library of wrong type field is provided May 14, 2026
@oguzhanduran oguzhanduran requested a review from svvald May 15, 2026 10:05

const dataInKetFormat = await this.ensureMonomersLibraryDataInKetFormat(
// Filter out SDF entries with invalid type before Indigo conversion
const validatedMonomersData = this.filterSdfIfNeeded(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We should not parse SDF on Ketcher client-side, it's completely Indigo's responsibility to parse it and return some errors if anything goes wrong

@AlexeyGirin
Copy link
Copy Markdown
Collaborator

Not actual since problem is on Indigo side

@AlexeyGirin AlexeyGirin closed this Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System should not add monomer to the library of wrong type field is provided

5 participants