epam / epam/Indigo

System should not add monomer to the library of empty value for type field is provided

Open
#3,878 1 comment 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:

_Base2

```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 _Base2 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/_Base2/_Base2 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 C -3.464 0.25 0.0 0\nM V30 3 P -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=_Base2 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> \n\n> \n_Base2_HELM\n\n> \nbase=_Base2\n\n$$$$\n', { format: 'sdf' })
```


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

**Expected behavior**
No monomers added, error in console should be thrown: `Empty value for "type" is provided. "_Base2" 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

Research direction

Start at the ketcher.updateMonomersLibrary entry point and trace how the SDF type field is parsed and validated. Reproduce the supplied command in the Macromolecules Flex mode console, then verify that an empty type produces the stated error and does not add _Base2 to the library.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, javascript, wasm
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.