Skip to content

Fix ub-test-reports link properties overwriting when mapped to same link field (#2058) - #2088

Closed
0xrutabaga wants to merge 1 commit into
useblocks:masterfrom
0xrutabaga:fix/issue-2058-merge-link-properties
Closed

0xrutabaga wants to merge 1 commit into
useblocks:masterfrom
0xrutabaga:fix/issue-2058-merge-link-properties

Conversation

@0xrutabaga

Copy link
Copy Markdown

Summary

Fixes an issue in ub-test-reports where multiple XML properties mapped onto the same link field overwrite each other instead of merging.

Closes #2058.

Problem / Root Cause

In build_need, iterating over link_properties.items() directly assigned need[link_field] = [item.strip() for item in raw.split(",") if item.strip()]. If multiple properties were mapped to the same field, subsequent properties unconditionally replaced earlier ones. Furthermore, if a mapped property was missing from a test case, it evaluated to empty, erasing previously extracted links.

Solution

  • Pre-initialize all mapped link_field targets to [].
  • For non-empty property values, merge and deduplicate while preserving comma/mapping order using list(dict.fromkeys(existing + items)).
  • Leave existing links intact when subsequent mapped properties are absent or empty.
  • Added changelog entry in packages/ub-test-reports/docs/changelog.rst.

Tests Added

  • Added unit tests in packages/ub-test-reports/tests/test_needs_export.py verifying multi-property merging, deduplication, order preservation, and absent property preservation.
  • Added CLI conversion integration test in packages/ub-test-reports/tests/test_cli_convert.py.

Validation

  • uv run pytest packages/ub-test-reports/tests/test_needs_export.py: 53 passed.
  • uv run pytest packages/ub-test-reports/tests/test_cli_convert.py: 47 passed, 1 skipped.
  • uv run pytest packages/ub-test-reports/tests/test_cli_config.py: 36 passed.
  • uv run ruff check packages/ub-test-reports: All checks passed.
  • uv run ruff format --check packages/ub-test-reports: 24 files clean.
  • Limitation: Full repo test test_project_config.py was skipped locally due to Windows symlink privilege limitations.

…ink field (useblocks#2058)

## Summary
- In ub_test_reports.needs_export.build_need, merge values from multiple XML properties
  mapped onto the same link field instead of overwriting previous values.
- Pre-initialize all mapped link fields so empty fields are emitted unconditionally.
- Preserve mapping order and comma order, deduplicate IDs, and ignore empty or absent properties.
- Add regression tests in test_needs_export.py and test_cli_convert.py.
- Add changelog entry in packages/ub-test-reports/docs/changelog.rst.

Fixes useblocks#2058.
@github-actions github-actions Bot added the pkg: ub-test-reports Concerns the ub-test-reports package (packages/ub-test-reports): the Sphinx-free test-reports core label Oct 6, 2026
@chrisjsewell

Copy link
Copy Markdown
Member

Thanks for the quick fix. #2058 is now fixed through #2119, so I'm closing this one in its favour.

#2119 merges the same way (mapping order, each id once, the field still written when empty) and also pins the mapping through the [test_reports.build.needs] link_properties table — the config loader's path, not only the --link-property flags — with a mapping-order control, and documents the rule on the converter's page. Appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: ub-test-reports Concerns the ub-test-reports package (packages/ub-test-reports): the Sphinx-free test-reports core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 ub-test-reports: two link properties mapped onto one link field overwrite each other in the converter

2 participants