Skip to content

fix(stats): Only strip known global prefixes in strip_namespace - #718

Open
yiyche wants to merge 1 commit into
datacommonsorg:masterfrom
yiyche:fix-namespace-stripping
Open

fix(stats): Only strip known global prefixes in strip_namespace#718
yiyche wants to merge 1 commit into
datacommonsorg:masterfrom
yiyche:fix-namespace-stripping

Conversation

@yiyche

@yiyche yiyche commented Aug 11, 2026

Copy link
Copy Markdown
Member

Previously, the CSV importer blindly stripped everything before the first colon, which dropped custom namespaces (like oecd:). This updates strip_namespace and strip_namespace_series to strictly target known prefixes (dcid:, dcs:, schema:).

Previously, the CSV importer blindly stripped everything before the first colon, which aggressively dropped custom namespaces (like oecd:). This updates strip_namespace and strip_namespace_series to strictly target known prefixes (dcid:, dcs:, schema:).
@yiyche
yiyche requested review from clincoln8 and kmoscoe August 11, 2026 04:45
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the namespace stripping logic in simple/stats/data.py to only strip specific global prefixes (dcid:, dcs:, and schema:) instead of splitting on any colon, and adds corresponding unit tests. The reviewer suggests removing this prefix-stripping logic entirely, advising against adding defensive input-cleaning code for patterns that are guaranteed by the system's architecture to never occur.

Comment thread simple/stats/data.py
_DCS_PREFIX = "dcs:"

_NAMESPACE_DELIMITER = ':'
_GLOBAL_PREFIXES = ("dcid:", "dcs:", "schema:")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Avoid adding defensive code or input-cleaning logic (such as stripping prefixes) for states or patterns that are guaranteed by the system's architecture or design to never occur in the input data. We should remove this prefix stripping logic entirely.

References
  1. Avoid adding defensive code or input-cleaning logic (such as stripping prefixes) for states or patterns that are guaranteed by the system's architecture or design to never occur in the input data.

Comment thread simple/stats/data.py
provenance_ids: list[str] = field(default_factory=list)
source_ids: list[str] = field(default_factory=list)

def add_provenance(self, provenance: "Provenance") -> "StatVarGroup":

@kmoscoe kmoscoe Aug 11, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does the call to the strip_namespace method need to be somewhere here as well?

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.

2 participants