Class: Dependabot::Uv::FileUpdater::LockFileErrorHandler

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/uv/file_updater/lock_file_error_handler.rb

Constant Summary collapse

UV_UNRESOLVABLE_REGEX =
T.let(/× No solution found when resolving dependencies.*[\s\S]*$/, Regexp)
UV_BUILD_FAILED_REGEX =
T.let(/× Failed to build.*[\s\S]*$/, Regexp)
RESOLUTION_IMPOSSIBLE_ERROR =
T.let("ResolutionImpossible", String)
GIT_DEPENDENCY_UNREACHABLE_REGEX =
T.let(%r{git clone.*(?<url>https?://[^\s]+)}, Regexp)
GIT_REFERENCE_NOT_FOUND_REGEX =
T.let(
  /Did not find branch or tag '(?<tag>[^\n"']+)'/m,
  Regexp
)
GIT_CREDENTIALS_ERROR_REGEX =
T.let(
  /could not read Username for '(?<url>[^']+)'/,
  Regexp
)
GIT_DEPENDENCY_URL_FROM_UV_REGEX =
T.let(
  %r{git\+(?<url>https?://[^\s@#]+)},
  Regexp
)
PYTHON_VERSION_ERROR_REGEX =
T.let(
  /Requires-Python|requires-python|python_requires|Python version/i,
  Regexp
)
AUTH_ERROR_REGEX =
T.let(
  /authentication|unauthorized|forbidden|HTTP status code: 40[13]/i,
  Regexp
)
TIMEOUT_ERROR_REGEX =
T.let(
  /timed?\s*out|connection.*reset|read timeout|connect timeout/i,
  Regexp
)
NETWORK_ERROR_REGEX =
T.let(
  Regexp.union(
    /ConnectionError/i,
    /NetworkError/i,
    /SSLError/i,
    /certificate verify failed/i,
    /connection refused/i,
    /dns.*failed/i,
    /error sending request/i
  ),
  Regexp
)
PACKAGE_NOT_FOUND_REGEX =
T.let(
  /No matching distribution found|package.*not found|No versions found/i,
  Regexp
)
UV_REQUIRED_VERSION_REGEX =
T.let(
  /Required uv version `(?<required>[^`]+)` does not match the running version `(?<running>[^`]+)`/,
  Regexp
)
TOML_PARSE_ERROR_REGEX =
T.let(
  /Failed to parse:?\s*`?(?<file>[^`\n]+\.toml)`?|TOML parse error/i,
  Regexp
)
USING_CPYTHON_LINE_REGEX =

uv prefixes errors with interpreter info that should be stripped

T.let(
  /\AUsing CPython \S+ interpreter at: [^\n]+\n?/,
  Regexp
)
PYPROJECT_SCHEMA_ERROR_REGEX =
T.let(
  /missing field `project`|missing.*\[project\].*table|Field `project\.name` is required/i,
  Regexp
)
WORKSPACE_MEMBER_ERROR_REGEX =
T.let(
  /Failed to find workspace member|No `pyproject\.toml` found in workspace member/i,
  Regexp
)
PATH_DEPENDENCY_ERROR_REGEX =
T.let(
  /Failed to read `(?<path>[^`]+)`|failed to read from file `(?<path>[^`]+)`/i,
  Regexp
)
HTTP_STATUS_ERROR_REGEX =
T.let(
  /HTTP status code: (?<code>\d{3})/i,
  Regexp
)
UV_MISCONFIGURED_REGEX =
T.let(
  Regexp.union(
    /unknown field `[^`]+`, expected one of/i,
    /Unrecognized.*value:/i,
    /URL scheme `[^`]+` is not supported/i,
    /Failed to parse URL/i,
    /the argument '--[^']+' cannot be used/i
  ),
  Regexp
)
MAX_ERROR_LINES =

Maximum number of lines to include in cleaned error messages. This limit ensures error messages remain readable while providing enough context for debugging. Most uv error messages convey the key information within the first few lines.

T.let(10, Integer)

Instance Method Summary collapse

Instance Method Details

#handle_uv_error(error) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/dependabot/uv/file_updater/lock_file_error_handler.rb', line 106

def handle_uv_error(error)
  message = error.message

  handle_required_version_errors(message)
  handle_pyproject_errors(message)
  handle_resolution_errors(message)
  handle_git_errors(message)
  handle_authentication_errors(message)
  handle_network_errors(message)
  handle_python_version_errors(message)
  handle_resource_errors(message)
  handle_package_not_found_errors(message)
  handle_uv_fallback_error(message)

  raise error
end