Skip to content

fix: Make project_id optional in results.py functions#204

Open
sanjeed5 wants to merge 1 commit intogenerate-v1.xfrom
fix/optional-project-id-results
Open

fix: Make project_id optional in results.py functions#204
sanjeed5 wants to merge 1 commit intogenerate-v1.xfrom
fix/optional-project-id-results

Conversation

@sanjeed5
Copy link
Contributor

@sanjeed5 sanjeed5 commented Feb 9, 2026

Summary

  • get_run_result(), get_run_metrics(), and compare_runs() in results.py all had project_id as a required positional argument, but none of them pass it to the backend (auth scopes handle project resolution).
  • This caused TypeError when calling these functions without project_id, which is how the docs, Sphinx reference, and sample app all use them.
  • Changed project_id: str to project_id: Optional[str] = None in all three functions. Fully backwards compatible - existing callers that pass project_id still work.

Test plan

  • Verify compare_runs(client, new_run_id, old_run_id) works without project_id
  • Verify get_run_result(client, run_id) works without project_id
  • Verify existing callers that pass project_id (e.g. core.py) still work

Made with Cursor


Note

Low Risk
Signature/docstring-only change that preserves existing behavior and is unlikely to affect runtime beyond allowing more valid call patterns.

Overview
Makes project_id an optional, deprecated parameter in get_run_result(), get_run_metrics(), and compare_runs() so callers can omit it without hitting TypeError, while keeping backwards compatibility for existing call sites.

Updates typing/imports and docstrings/examples to reflect that project resolution is handled by backend auth scopes and project_id is accepted but ignored.

Written by Cursor Bugbot for commit 9a019d6. This will update automatically on new commits. Configure here.

project_id was a required positional argument in get_run_result(),
get_run_metrics(), and compare_runs(), but none of them pass it to
the backend - auth scopes handle project resolution. This caused
TypeError when callers followed the docs/examples which omit it.

Make project_id Optional[str] = None for backwards compatibility.

Co-authored-by: Cursor <cursoragent@cursor.com>
@snyk-io
Copy link

snyk-io bot commented Feb 9, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@sanjeed5
Copy link
Contributor Author

@claude review

@claude
Copy link
Contributor

claude bot commented Feb 24, 2026

Claude finished @sanjeed5's task in 1m 21s —— View job


Review of PR #204 complete

  • Read changed files and gather context
  • Check callers and usage patterns
  • Post code-level inline feedback
  • Post top-level review summary

Result: This is a clean, low-risk fix. The change correctly makes project_id optional in get_run_result(), get_run_metrics(), and compare_runs(), aligning the signatures with reality (the parameter was already ignored). Fully backwards-compatible — existing callers in core.py and external code that passes project_id still work.

One non-blocking suggestion posted as an inline comment: emit a DeprecationWarning when project_id is actually passed, so users discover they can simplify their calls.

client: Any, # HoneyHive client
run_id: str,
project_id: str,
project_id: Optional[str] = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion (non-blocking): The docstring says "Deprecated" but no DeprecationWarning is emitted when a caller actually passes a value. For a published SDK, it's good practice to emit a warning so users know to update their code. Same applies to get_run_metrics and compare_runs.

Suggested change
project_id: Optional[str] = None,
project_id: Optional[str] = None,

Consider adding something like this at the top of each function body:

if project_id is not None:
    import warnings
    warnings.warn(
        "project_id is deprecated and ignored; backend uses auth scopes for project resolution.",
        DeprecationWarning,
        stacklevel=2,
    )

This isn't blocking — the current approach is already backwards-compatible and safe. But emitting a warning would help users discover they can simplify their call sites.

@claude
Copy link
Contributor

claude bot commented Feb 24, 2026

Review Summary

Verdict: Approve — This is a clean, well-motivated fix. The change is low-risk, fully backwards-compatible, and addresses a real TypeError that users hit when following the docs/examples.

What looks good

  • Backwards compatibility preserved: The existing caller in core.py:1106-1111 passes project_id=project as a keyword argument, so it continues to work. Any external callers passing project_id positionally also still work since the parameter stays in the same position.
  • Correct diagnosis: The original code required project_id but never passed it to the backend (the old comments even acknowledged this: "Note: project_id is no longer passed"). Making it optional aligns the signature with reality.
  • Formatting fix for get_run_metrics: The original had a cramped single-line signature with the # HoneyHive client comment misplaced after the return type. The PR correctly reformats this and moves the comment to client.
  • Docstring examples updated: The examples now show the intended call pattern without project_id.

One suggestion (posted as inline comment)

Since the docstrings say "Deprecated", consider emitting a DeprecationWarning when project_id is actually provided. This would help users discover they can simplify their call sites. Not blocking — the current approach is safe.

Documentation

No doc updates needed. The change makes the code match what the docs/examples already show (calling without project_id).

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.

1 participant