Skip to content

[scc-mcp] Error messages in NotFound exception handlers format project_id as None when querying by organization_id #296

Description

@dandye

Description

In server/scc/scc_mcp.py, when calling top_vulnerability_findings or get_finding_remediation with organization_id (and leaving project_id=None), any google.api_core.exceptions.NotFound exception formats the error message referencing project_id.

Root Cause

In server/scc/scc_mcp.py:

  • In top_vulnerability_findings:
    except google_exceptions.NotFound as e:
        logger.error(f"Project or resource not found for top findings on {parent}: {e}")
        return {"error": "Not Found", "details": f"Could not find project '{project_id}' or relevant resources. {str(e)}"}
  • In get_finding_remediation:
    except google_exceptions.NotFound as e:
        logger.error(f"Resource not found during SCC operation for project {project_id} (finding_id: {finding_id}, resource: {resource_name}): {e}")
        return {"error": "Not Found", "details": f"Could not find project '{project_id}' or related SCC resources. {str(e)}"}

When an organization-level query fails with NotFound, the returned details string outputs:

Could not find project 'None' or relevant resources.

Proposed Fix

Update exception handlers to dynamically format the scope label based on which identifier was provided:

target_scope = f"organization '{organization_id}'" if organization_id else f"project '{project_id}'"
return {"error": "Not Found", "details": f"Could not find {target_scope} or relevant resources. {str(e)}"}

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions