Skip to content

GitHub Issue 1028: Can't delete a sample when any sample in the sample type has been linked to study#7572

Open
XingY wants to merge 3 commits intorelease26.3-SNAPSHOTfrom
26.3_fb_issue1028
Open

GitHub Issue 1028: Can't delete a sample when any sample in the sample type has been linked to study#7572
XingY wants to merge 3 commits intorelease26.3-SNAPSHOTfrom
26.3_fb_issue1028

Conversation

@XingY
Copy link
Copy Markdown
Contributor

@XingY XingY commented Apr 10, 2026

Rationale

Issue link
Users shouldn't need permission on the linked study container to delete samples that are not linked.

Related Pull Requests

Changes

@XingY XingY requested a review from cnathe April 10, 2026 18:03
SimpleFilter filter = new SimpleFilter(FieldKey.fromParts(ExpMaterialTable.Column.RowId.toString()), material.getRowId());
String lsid = new TableSelector(tableInfo, singleton("LSID"), filter, null).getObject(String.class);
UserSchema schemaWithReadPerm = QueryService.get().getUserSchema(userWithReadPerm, dataset.getContainer(), "study");
TableInfo tableInfoForRead = schemaWithReadPerm.getTable(dataset.getName());
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.

we have a null check on the tableInfo for the dataset below. Do we need it for this tableInfoForRead case as well?

UserSchema schema = QueryService.get().getUserSchema(user, dataset.getContainer(), "study");
TableInfo tableInfo = schema.getTable(dataset.getName());
// Need Read permission to check for linked samples
User userWithReadPerm = ElevatedUser.getElevatedUser(user, ReaderRole.class);
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.

minor: this could be moved outside of the for loop instead of creating the elevated user for each container loop.


// Create sample timeline event for each of the samples
if (sourceType == Dataset.PublishSource.SampleType && pairs != null)
if (sourceType == Dataset.PublishSource.SampleType && rowIds != null && rowIds.isEmpty())
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.

shouldn't this be && !rowIds.isEmpty()? it is missing the "not" part, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Fix and added selenium test.

@XingY XingY requested a review from cnathe April 10, 2026 19:31
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