Skip to content

Avoid logging UnauthorizedException visiting exp.Files as reader #6601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 24, 2025

Conversation

labkey-jeckels
Copy link
Contributor

Rationale

org.labkey.api.view.UnauthorizedException: You do not have permission to insert data into this table.
	at org.labkey.api.query.AbstractQueryUpdateService._insertRowsUsingInsertRow(AbstractQueryUpdateService.java:560) ~[api-25.5-SNAPSHOT.jar:?]
	at org.labkey.api.query.AbstractQueryUpdateService.insertRows(AbstractQueryUpdateService.java:673) ~[api-25.5-SNAPSHOT.jar:?]
	at org.labkey.filecontent.FileContentServiceImpl.ensureFileData(FileContentServiceImpl.java:1543) [filecontent-25.5-SNAPSHOT.jar:?]
	at org.labkey.experiment.api.ExpFilesTableImpl.getFromSQL(ExpFilesTableImpl.java:64) [experiment-25.5-SNAPSHOT.jar:?]
	at org.labkey.api.query.FilteredTable.getFromSQL(FilteredTable.java:516) [api-25.5-SNAPSHOT.jar:?]
	at org.labkey.api.data.AbstractTableInfo.getFromSQLExpanded(AbstractTableInfo.java:407) [api-25.5-SNAPSHOT.jar:?]
	at org.labkey.api.data.AbstractTableInfo.getFromSQL(AbstractTableInfo.java:402) [api-25.5-SNAPSHOT.jar:?]
	at org.labkey.query.sql.QuerySelectView.getSelectSQL(QuerySelectView.java:336) [query-25.5-SNAPSHOT.jar:?]
	at org.labkey.query.sql.QuerySelectView.getSql(QuerySelectView.java:163) [query-25.5-SNAPSHOT.jar:?]
	at org.labkey.query.QueryServiceImpl$SelectBuilderImpl.buildSqlFragment(QueryServiceImpl.java:2865) [query-25.5-SNAPSHOT.jar:?]
	at org.labkey.query.controllers.QueryController$SelectDistinctAction.getDistinctSql(QueryController.java:3818) [query-25.5-SNAPSHOT.jar:?]
	at org.labkey.query.controllers.QueryController$SelectDistinctAction.execute(QueryController.java:3731) [query-25.5-SNAPSHOT.jar:?]
	at org.labkey.query.controllers.QueryController$SelectDistinctAction.execute(QueryController.java:3721) [query-25.5-SNAPSHOT.jar:?]
	at org.labkey.api.action.BaseApiAction.handlePost(BaseApiAction.java:240) [api-25.5-SNAPSHOT.jar:?]
	at org.labkey.api.action.ReadOnlyApiAction.handleGet(ReadOnlyApiAction.java:46) [api-25.5-SNAPSHOT.jar:?]
	at org.labkey.api.action.BaseApiAction.handleRequest(BaseApiAction.java:132) [api-25.5-SNAPSHOT.jar:?]
	at org.labkey.api.action.BaseViewAction.handleRequest(BaseViewAction.java:190) [api-25.5-SNAPSHOT.jar:?]
	at org.labkey.api.action.ReadOnlyApiAction.handleRequest(ReadOnlyApiAction.java:40) [api-25.5-SNAPSHOT.jar:?]
	at org.labkey.api.action.SpringActionController.handleRequest(SpringActionController.java:527) [api-25.5-SNAPSHOT.jar:?]
	at org.labkey.api.module.DefaultModule.dispatch(DefaultModule.java:1124) [api-25.5-SNAPSHOT.jar:?]

Changes

  • Avoid doing the work to enumerate files and insert them into exp.Data when the user doesn't have permissions

@labkey-jeckels labkey-jeckels requested a review from XingY April 23, 2025 22:51
if (!container.hasPermission(user, InsertPermission.class))
{
// Could also swap in a service user, like User.getAdminServiceUser()
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we should swap the user? It probably makes sense to have this table always populated by service user, instead of whoever first hits it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that makes sense. I've pushed a followup commit that always uses the service user.

@labkey-jeckels labkey-jeckels merged commit e596ed3 into develop Apr 24, 2025
5 checks passed
@labkey-jeckels labkey-jeckels deleted the fb_insertExpFiles2 branch April 24, 2025 23:37
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