loblaw-sre / backstage-plugin-gitlab

Backstage plugin for Gitlab
53 stars 31 forks source link

Bug in the IssuesTable component #208

Open PedroHPAlmeida opened 2 years ago

PedroHPAlmeida commented 2 years ago

In line 68 of the IssuesTable.tsx file a check is made to assign the variable projectId the value of project_id (if it was passed as a parameter to the component), otherwise the value of the id attribute of the projectDetails object is passed.

const { value, loading, error } = useAsync(async (): Promise<{
    data: IssueObject[];
    projectName: string;
    }> => {
        let projectDetails: any = await GitlabCIAPI.getProjectDetails(project_slug);
        let projectId = project_id ? project_id : projectDetails?.id; // Line 68
        let projectName = await GitlabCIAPI.getProjectName(projectId);
        const gitlabIssuesObject = await GitlabCIAPI.getIssuesSummary(project_id); // Line 70 - The error occurs here
        const data = gitlabIssuesObject?.getIssuesData;
        let renderData: any = { data, projectName };

        return renderData;
}, []);

The error occurs when the project_id parameter is not passed to the component and on line 70 the request is made by passing an undefined value. This happens when the catalog-info.yaml file has only the gitlab.com/project-slug annotation. The solution is simple: just pass the variable projectId (not project_id) when calling the API, as is done in other components such as PipelinesTable.tsx.

Parsifal-M commented 1 year ago

Hey! @PedroHPAlmeida

Is this why issues are not loading into the UI? I noticed in the API request it returns a 404 when trying to fetch issues.

I can take a look at this potentially if I have some time seeing as it has been open for a while.

PedroHPAlmeida commented 1 year ago

That's right, @Parsifal-M! By cloning the plugin into my project, and making the changes I suggested, the problem was solved.

Parsifal-M commented 1 year ago

Hey @PedroHPAlmeida :wave:

Thanks for the heads up! I've raised a PR for this, hopefully, we can get it fixed.

Cheers!

JellyBellyDev commented 1 year ago

Hi @PedroHPAlmeida and @Parsifal-M I suggest you to switch to the new official backstage-plugin-gitlab: https://github.com/immobiliare/backstage-plugin-gitlab ;)

Parsifal-M commented 1 year ago

Hi @PedroHPAlmeida and @Parsifal-M I suggest you to switch to the new official backstage-plugin-gitlab: https://github.com/immobiliare/backstage-plugin-gitlab ;)

Ah, thanks for the heads up. :+1: