Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 27, 2025

Model constructor accepted non-existent URLs/IDs without validation, causing confusing errors later during predict() or load_info() calls.

Changes

  • Added early validation: _validate_model_exists() makes a GetModel request during __init__ to verify model existence
  • Clear error messages: Distinguish URL vs ID-based errors with full context (URL, status, details)
  • Performance preservation: Added validate=False parameter used internally in list_versions(), create_version(), etc. to skip redundant checks
  • Test coverage: Integration tests for real API validation + mock-based unit tests for validation logic

Example

# Before: confusing error during usage
model = Model(url="https://clarifai.com/user/app/models/nonexistent")
model.predict(...)  # Error: Model not found (unclear where/why)

# After: immediate, clear error at construction
model = Model(url="https://clarifai.com/user/app/models/nonexistent")
# UserError: Model does not exist or cannot be accessed at URL: https://clarifai.com/user/app/models/nonexistent
# Status: Model not found
# Details: The requested model does not exist

Fully backward compatible - validate defaults to True.

Original prompt

This section details on the original issue you should resolve

<issue_title>Improve error handling for non-existent model URL in Model constructor</issue_title>
<issue_description>The current error handling for the Model constructor does not catch cases where a non-existent model URL is passed. This results in a confusing error message later in the process. The error should be caught earlier and should clearly indicate that the model URL is invalid or the model does not exist.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Improve error handling for non-existent model URL in Model constructor Validate model existence in constructor to fail fast with clear errors Oct 27, 2025
Copilot finished work on behalf of srikanthbachala20 October 27, 2025 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Improve error handling for non-existent model URL in Model constructor

2 participants