Skip to content

fix(context): dict_parser reads aliases key for dimension/metric synonyms - #29

Open
Zyl0812 wants to merge 1 commit into
agentscope-ai:mainfrom
Zyl0812:fix/dict-parser-aliases-synonyms-key
Open

fix(context): dict_parser reads aliases key for dimension/metric synonyms#29
Zyl0812 wants to merge 1 commit into
agentscope-ai:mainfrom
Zyl0812:fix/dict-parser-aliases-synonyms-key

Conversation

@Zyl0812

@Zyl0812 Zyl0812 commented Aug 20, 2026

Copy link
Copy Markdown

What

dict_parser._convert_dimensions and _convert_metrics read a
synonyms key that doesn't exist on the wire contract, so every
dimension/metric alias imported through the Excel semantic-config
flow (POST /api/semantic-config/import/excel) is silently dropped
when weave runs -- the graph ends up with empty synonyms arrays,
and weave still reports SUCCESS.

Why

SemanticImportRequest's DimensionPayload/MetricPayload
(contracts/import_models.py) only define an aliases field.
weave_assembler.py produces payloads keyed on aliases
accordingly. But dict_parser.py:312 and :416 read
dim.get("synonyms") / met.get("synonyms"), which is always
None for these payloads -- the two spots weren't updated when the
domain-alias (dict_parser.py:58) and dimension-value-alias
(dict_parser.py:346) conversions were already fixed to read
aliases.

Found while importing ~1,800 real dimension/metric definitions
through the Excel flow: metric.synonyms and dimension.synonyms
were [] for every node after weave, despite the source Excel
having non-empty synonyms columns for ~1,400 of them.

Fix

Read aliases first, fall back to synonyms (keeps the legacy
YAML-based import path working, since that path already uses
synonyms as the key name).

How verified

  • Added tests/test_dict_parser_synonyms.py: 4 cases covering
    _convert_dimensions/_convert_metrics reading aliases, and
    falling back to synonyms.
  • Confirmed the new tests fail against the pre-fix code (both
    "reads aliases" cases fail with an empty list) and pass after
    the fix.
  • uv run python -m compileall packages and
    uv run pytest -q packages/datapaw-context/tests (152 passed)
    both clean.

SemanticImportRequest's DimensionPayload/MetricPayload only define an
`aliases` field (see contracts/import_models.py); there is no `synonyms`
field on the wire. dict_parser._convert_dimensions/_convert_metrics read
`dim.get("synonyms")`/`met.get("synonyms")`, which is always None for
payloads produced by weave_assembler, so every alias imported via the
Excel semantic-config flow was silently dropped during weave (weave
still returns SUCCESS, no error surfaced).

Read `aliases` first, falling back to `synonyms` for the legacy YAML
import path -- matching the pattern already used for domain aliases
(dict_parser.py:58) and dimension value aliases (dict_parser.py:346).

Add regression tests covering both keys for _convert_dimensions and
_convert_metrics.

Signed-off-by: zhouyilong <zhouyilong@mysteel.com>
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.

1 participant