Exception: Kotoshu::IntegrityError
- Defined in:
- lib/kotoshu/core/exceptions.rb
Overview
Error raised when a downloaded resource fails integrity verification (SHA-256 mismatch against manifest, truncated content, etc.).
The downloaded bytes are never trusted until verified against a known manifest entry. Mismatch raises this error with both hashes so the caller can surface them in audit logs and CI output.
The optional remediation: hint is appended to the message when the
caller knows the user-facing fix (e.g. "Run kotoshu cache download :en --model to re-download"). Existing callers that omit it see no
change in the message format.
Instance Attribute Summary collapse
-
#actual ⇒ Object
readonly
Returns the value of attribute actual.
-
#expected ⇒ Object
readonly
Returns the value of attribute expected.
-
#remediation ⇒ Object
readonly
Returns the value of attribute remediation.
-
#resource_id ⇒ Object
readonly
Returns the value of attribute resource_id.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(resource_id, expected:, actual:, url: nil, remediation: nil) ⇒ IntegrityError
constructor
A new instance of IntegrityError.
Constructor Details
#initialize(resource_id, expected:, actual:, url: nil, remediation: nil) ⇒ IntegrityError
Returns a new instance of IntegrityError.
157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/kotoshu/core/exceptions.rb', line 157 def initialize(resource_id, expected:, actual:, url: nil, remediation: nil) @resource_id = resource_id @expected = expected @actual = actual @url = url @remediation = remediation msg = "Integrity verification failed for #{resource_id}: " msg << "expected sha256=#{expected}, got sha256=#{actual}" msg << " (url: #{url})" if url msg << ". #{remediation}" if remediation super(msg) end |
Instance Attribute Details
#actual ⇒ Object (readonly)
Returns the value of attribute actual.
170 171 172 |
# File 'lib/kotoshu/core/exceptions.rb', line 170 def actual @actual end |
#expected ⇒ Object (readonly)
Returns the value of attribute expected.
170 171 172 |
# File 'lib/kotoshu/core/exceptions.rb', line 170 def expected @expected end |
#remediation ⇒ Object (readonly)
Returns the value of attribute remediation.
170 171 172 |
# File 'lib/kotoshu/core/exceptions.rb', line 170 def remediation @remediation end |
#resource_id ⇒ Object (readonly)
Returns the value of attribute resource_id.
170 171 172 |
# File 'lib/kotoshu/core/exceptions.rb', line 170 def resource_id @resource_id end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
170 171 172 |
# File 'lib/kotoshu/core/exceptions.rb', line 170 def url @url end |