Skip to content

Conversation

@XingY
Copy link
Contributor

@XingY XingY commented Sep 25, 2025

Rationale

Related Pull Requests

Changes

  • remove support for non-webdav path based query import
  • refactor File constructor/resolve usages

@labkey-klum labkey-klum requested a review from Copilot September 26, 2025 23:34
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 addresses path-related warnings by replacing direct path resolution methods with FileUtil utility methods throughout the codebase. The changes aim to improve path handling consistency and likely address security or compatibility concerns related to path traversal.

  • Replace direct Path.resolve() calls with FileUtil.appendName()
  • Replace new File(parent, child) constructors with FileUtil.appendName()
  • Add path traversal validation in file handling
  • Update method signatures with null safety annotations

Reviewed Changes

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

Show a summary per file
File Description
StudyImportContext.java Replace path resolution with FileUtil.appendName
StudyPublishManager.java Replace path resolution with FileUtil.appendName
PipelineServiceImpl.java Replace path resolution with FileUtil.appendName
FileSystemAttachmentParent.java Replace path resolution with FileUtil.appendName
FileContentServiceImpl.java Add null annotations and replace path construction
ExperimentPipelineProvider.java Replace path resolution with FileUtil.appendName
ExperimentController.java Replace path resolution with FileUtil.appendName
FileType.java Replace path resolution and File constructor with FileUtil methods
AbstractQueryImportAction.java Refactor path handling with improved validation
LocalDirectory.java Replace path resolution with FileUtil.appendName
AnalyzeForm.java Add FileUtil import and replace path resolution
FileContentService.java Add null annotation to method signature
AbstractFileXarSource.java Add path traversal validation
FileAttachmentFile.java Add null safety checks
AssayRunUploadForm.java Add FileUtil import and replace File constructor

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

public File newFile(File parent, String basename)
{
return new File(parent, getName(parent, basename));
return FileUtil.appendName(parent, getName(parent, basename));
Copy link

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

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

The return type is File but FileUtil.appendName(File, String) likely returns a Path or different type. This will cause a compilation error.

Suggested change
return FileUtil.appendName(parent, getName(parent, basename));
return FileUtil.appendName(parent, getName(parent, basename)).toFile();

Copilot uses AI. Check for mistakes.
{
// For local, the path may be several directories deep (since it matches the LK folder path), so we should create the directories for that path
fileRootPath = new File(parentRoot.toFile(), getRelativePath(c, firstOverride)).toPath();
fileRootPath = FileUtil.appendPath(parentRoot.toFile(), Path.parse(getRelativePath(c, firstOverride))).toPath();
Copy link

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

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

This code converts Path to File, then back to Path unnecessarily. Should use FileUtil.appendPath directly with Path objects or use a consistent approach.

Suggested change
fileRootPath = FileUtil.appendPath(parentRoot.toFile(), Path.parse(getRelativePath(c, firstOverride))).toPath();
fileRootPath = FileUtil.appendPath(parentRoot, Path.parse(getRelativePath(c, firstOverride)));

Copilot uses AI. Check for mistakes.
public FileAttachmentFile(FileLike file)
{
this(file.toNioPathForRead().toFile(), null);
this(file == null ? null : file.toNioPathForRead().toFile(), null);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably prohibit null for the file. Lots of methods will NPE if _file is null.

File f = new File(path);
if (!root.isUnderRoot(f))
f = root.resolvePath(path);
Path relativePath = Path.parse(path);
Copy link
Contributor

Choose a reason for hiding this comment

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

I looked at the history and came to the same conclusion - this has been broken since 24.11. Let's get rid of both the relative and absolute variants here, but retain the webdav part above.

@XingY XingY merged commit 0a066b5 into develop Sep 29, 2025
9 checks passed
@XingY XingY deleted the fb_filePathWarning branch September 29, 2025 19:24
@XingY XingY mentioned this pull request Sep 29, 2025
XingY added a commit that referenced this pull request Sep 29, 2025
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.

3 participants