Skip to content

[Bug]: Offer filter suggests public projects the user hasn't joined #4461

Closed

Description

@r4victor

Steps to reproduce

  1. As an admin, create a public project with no fleets, e.g. pub, and add a non-admin user to one other project, e.g. main.
  2. Sign in to the UI as that user.
  3. Open Runs → Launch, or the Offers page.
  4. Open the Project property in the offer filter.

Actual behaviour

The filter suggests both main and pub, although the user is not a member of pub. The user gets 403 on that project's resources (e.g. POST /api/project/pub/fleets/list), so picking it leads nowhere.

The project isn't pre-selected either, even though the user has a single project: the auto-selection checks for exactly one project, and the public one makes it two.

The offer filter requests projects without username, so /api/projects/list returns every project visible to the user, public ones included:

const { data: projectsData } = useGetProjectsQuery({ limit: 2 });

await getProjects(
getTokenAwareNamePatternFilterRequestParams({
filteringText,
limit,
propertyKey: filterKeys.PROJECT_NAME,
tokens: propertyFilterQuery.tokens,
}),
)

let projectName = projectsData.data.length === 1 ? projectsData.data[0].project_name : undefined;

Expected behaviour

The filter suggests only the projects the user is a member of, and pre-selects the project when there is only one, like the project picker that #4449 switched to the user's projects:

const userName = useAppSelector(selectUserName);
const { data: projectsData, isLoading } = useGetProjectsQuery({ username: userName ?? '' }, { skip: !userName });

Open question: whether global admins should keep seeing all projects here, since they can use any of them.

dstack version

master (927b982), after 0.22.6

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions