Skip to content

HPCC-35234 Ensure XRef handles trailing extensions correctly#21051

Open
jackdelv wants to merge 1 commit intohpcc-systems:candidate-10.0.xfrom
jackdelv:issue35234
Open

HPCC-35234 Ensure XRef handles trailing extensions correctly#21051
jackdelv wants to merge 1 commit intohpcc-systems:candidate-10.0.xfrom
jackdelv:issue35234

Conversation

@jackdelv
Copy link
Contributor

@jackdelv jackdelv commented Mar 3, 2026

Type of change:

  • This change is a bug fix (non-breaking change which fixes an issue).
  • This change is a new feature (non-breaking change which adds functionality).
  • This change improves the code (refactor or other change that does not change the functionality)
  • This change fixes warnings (the fix does not alter the functionality or the generated code)
  • This change is a breaking change (fix or feature that will cause existing behavior to change).
  • This change alters the query API (existing queries will have to be recompiled)

Checklist:

  • My code follows the code style of this project.
    • My code does not create any new warnings from compiler, build system, or lint.
  • The commit message is properly formatted and free of typos.
    • The commit message title makes sense in a changelog, by itself.
    • The commit is signed.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly, or...
    • I have created a JIRA ticket to update the documentation.
    • Any new interfaces or exported functions are appropriately commented.
  • I have read the CONTRIBUTORS document.
  • The change has been fully tested:
    • I have added tests to cover my changes.
    • All new and existing tests passed.
    • I have checked that this change does not introduce memory leaks.
    • I have used Valgrind or similar tools to check for potential issues.
  • I have given due consideration to all of the following potential concerns:
    • Scalability
    • Performance
    • Security
    • Thread-safety
    • Cloud-compatibility
    • Premature optimization
    • Existing deployed queries will not be broken
    • This change fixes the problem, not just the symptom
    • The target branch of this pull request is appropriate for such a change.
  • There are no similar instances of the same problem that should be addressed
    • I have addressed them here
    • I have raised JIRA issues to address them separately
  • This is a user interface / front-end modification
    • I have tested my changes in multiple modern browsers
    • The component(s) render as expected

Smoketest:

  • Send notifications about my Pull Request position in Smoketest queue.
  • Test my draft Pull Request.

Testing:

Copilot AI review requested due to automatic review settings March 3, 2026 19:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to improve how XRef/DFS constructs and interprets part filenames when there are “extra” trailing extensions in masks (e.g., additional suffixes beyond the base/part naming).

Changes:

  • Avoid appending :: when there is no current scope while building XRef scope prefixes.
  • Extend constructPartFilename to preserve “trailing” extensions from pmask when lname is already provided.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
dali/sasha/saxref.cpp Adjusts scope prefix construction to avoid adding :: when scope is empty.
dali/base/dadfs.cpp Adds logic to detect and append trailing extensions from pmask onto generated physical part names.

else if (!isEmptyString(pmask))
{
// pmask may contain trailing extensions that aren't in lname
const char *ext = strchr(pmask, '.');
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

strchr(pmask, '.') searches the entire string, so if pmask includes a directory path containing dots (e.g. /var/lib/hpcc/v1.2/data/file._$P$), ext will point into the directory portion, and tailExt may become incorrect (or misleadingly non-null). This can result in appending the wrong substring to fullname, producing malformed filenames. Consider finding dots only in the basename portion of pmask (after the last path separator), or use an existing path/filename utility in the codebase to locate extensions reliably.

Suggested change
const char *ext = strchr(pmask, '.');
// Only consider dots in the basename portion (after the last path separator)
const char *filePart = pmask;
const char *lastSlash = strrchr(pmask, '/');
const char *lastBackslash = strrchr(pmask, '\\');
if (lastSlash || lastBackslash)
{
const char *lastSep = lastSlash;
if (!lastSep || (lastBackslash && lastBackslash > lastSep))
lastSep = lastBackslash;
filePart = lastSep + 1;
}
const char *ext = strchr(filePart, '.');

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

pmask comes from cFileDesc::getNameMask and will only ever contain the file name.

Comment on lines +322 to +323
assertex(ext); // pmask should have at least one extension for the part mask
tailExt = strchr(ext+1, '.');
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

The new assertex(ext) introduces a hard failure for any caller that passes a non-empty pmask without a . character (even if such masks were previously tolerated). Since this is a filename-construction helper, it’s safer to treat “no extension found” as “no trailing extension to append” (i.e., skip appending) rather than asserting and potentially aborting in production.

Suggested change
assertex(ext); // pmask should have at least one extension for the part mask
tailExt = strchr(ext+1, '.');
if (ext)
tailExt = strchr(ext+1, '.');

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It may not be the best to error on this, but it should always be the case that the pmask have at least one extension. Otherwise it would not have been able to deduce the part mask and this file would not make it here. It would be treated as an external file.

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

Jira Issue: https://hpccsystems.atlassian.net//browse/HPCC-35234

Jirabot Action Result:
Workflow Transition To: Merge Pending
Updated PR

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