epam / epam/Indigo

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

Open
#3,695 0 comments 0 reactions 0 assignees View on GitHub
Priority: Medium Severity: Medium
Dominant language
C++
Stars
406
Forks
134
Avg merge
2d 11h
Merged PRs (30d)
24

Description

**Steps to Reproduce**
1. Open Macromolecules - Flex mode (clean canvas)
2. Go to console and execute following commands:

_Base1

```javascript
await ketcher.updateMonomersLibrary('\n -INDIGO-10092512402D\n\n 0 0 0 0 0 0 0 0 0 0 0 V3000\nM V30 BEGIN CTAB\nM V30 COUNTS 1 0 0 0 0\nM V30 BEGIN ATOM\nM V30 1 _Base1 10.9051 -9.2 0.0 0 CLASS=BASE\nM V30 END ATOM\nM V30 BEGIN BOND\nM V30 END BOND\nM V30 END CTAB\nM V30 BEGIN TEMPLATE\nM V30 TEMPLATE 1 BASE/_Base1/_Base1 NATREPLACE=BASE/A\nM V30 BEGIN CTAB\nM V30 COUNTS 13 12 5 0 0\nM V30 BEGIN ATOM\nM V30 1 H -4.33 0.75 0.0 0\nM V30 2 P -3.464 0.25 0.0 0\nM V30 3 C -2.598 0.75 0.0 0\nM V30 4 C -1.732 0.25 0.0 0\nM V30 5 C -0.866 0.75 0.0 0\nM V30 6 C 0.0 0.25 0.0 0\nM V30 7 C 0.866 0.75 0.0 0\nM V30 8 C 1.732 0.25 0.0 0\nM V30 9 C 2.598 0.75 0.0 0\nM V30 10 C 3.464 0.25 0.0 0\nM V30 11 H 4.33 0.75 0.0 0\nM V30 12 H -3.464 -0.75 0.0 0\nM V30 13 H -1.732 -0.75 0.0 0\nM V30 END ATOM\nM V30 BEGIN BOND\nM V30 1 1 1 2\nM V30 2 1 2 3\nM V30 3 1 3 4\nM V30 4 1 4 5\nM V30 5 1 5 6\nM V30 6 1 6 7\nM V30 7 1 7 8\nM V30 8 1 8 9\nM V30 9 1 9 10\nM V30 10 1 10 11\nM V30 11 1 2 12\nM V30 12 1 4 13\nM V30 END BOND\nM V30 BEGIN SGROUP\nM V30 1 SUP 1 ATOMS=(1 1) XBONDS=(1 1) BRKXYZ=(9 0.433000 -0.250000 0.000000-\nM V30 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000) LABEL=H CLASS=-\nM V30 LGRP\nM V30 2 SUP 2 ATOMS=(1 11) XBONDS=(1 10) BRKXYZ=(9 -0.433000 -0.250000 0.000-\nM V30 000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000) LABEL=H CLA-\nM V30 SS=LGRP\nM V30 3 SUP 3 ATOMS=(1 12) XBONDS=(1 11) BRKXYZ=(9 0.000000 0.500000 0.00000-\nM V30 0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000) LABEL=H CLASS-\nM V30 =LGRP\nM V30 4 SUP 4 ATOMS=(1 13) XBONDS=(1 12) BRKXYZ=(9 0.000000 0.500000 0.00000-\nM V30 0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000) LABEL=H CLASS-\nM V30 =LGRP\nM V30 5 SUP 5 ATOMS=(9 2 3 4 5 6 7 8 9 10) XBONDS=(4 1 11 12 10) BRKXYZ=(9 --\nM V30 0.433000 0.250000 0.000000 0.000000 -0.500000 0.000000 0.000000 0.0000-\nM V30 00 0.000000) BRKXYZ=(9 0.000000 -0.500000 0.000000 0.433000 0.250000 0-\nM V30 .000000 0.000000 0.000000 0.000000) LABEL=_Base1 CLASS=BASE SAP=(3 2 1-\nM V30 Al) SAP=(3 10 11 Br) SAP=(3 2 12 Cx) SAP=(3 4 13 Dx) NATREPLACE=BASE/A\nM V30 END SGROUP\nM V30 END CTAB\nM V30 END TEMPLATE\nM END\n> \nwrongTypeHere\n\n> \n_Base1_HELM\n\n> \nbase=_Base1\n\n$$$$\n', { format: 'sdf' })
```


**Actual behavior**
`_Base1` base appeared in the Library
Image

**Expected behavior**
No monomers added, error in console should be thrown: `Type: "wrongTypeHere" is unknown. "_Base1" monomer hasn't been added to the library.`

As per [requirement](https://github.com/epam/Indigo/issues/3161):
> - type - optional. Default: `monomerTemplate`. Possible values: `monomerTemplate`, `monomerGroupTemplate`(used only for presets now. Can be used for other groups of monomers in future).
>
> No value provided: Skip monomer load with an error
> In case of error: Skip monomer load with an error

**Environment details:**
- Ketcher Version 3.9.0-rc.1 Build at 2025-10-02; 16:35:40
- Indigo Version 1.37.0-rc.1.0-gca09660df-wasm32-wasm-clang-19.0.0
- Chrome Version 141.0.7390.55 (Official Build) (64-bit)
- Win10

Related issue: https://github.com/epam/Indigo/issues/3161

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.