Skip to content

Bug: repo_info endpoint missing graph_exists() check #580

@gkorland

Description

@gkorland

Description

The repo_info endpoint in api/index.py creates a Graph(repo) and calls g.stats() without first checking graph_exists(repo):

@app.route('/api/repo_info', methods=['POST'])
@public_access
@token_required
def repo_info():
    data = request.get_json()
    repo = data.get('repo')
    if repo is None:
        return jsonify({'status': 'Missing mandatory parameter "repo"'}), 400

    g = Graph(repo)        # No graph_exists() check
    stats = g.stats()
    info = get_repo_info(repo)
    ...

Other endpoints like graph_entities, get_neighbors, and find_paths all check graph_exists(repo) before proceeding.

Suggested Fix

Add the same guard:

if not graph_exists(repo):
    return jsonify({'status': f'Missing project {repo}'}), 400

Context

Found during code review of PR #522.

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