Exemplo
mustermann 4.0.0: Distinguish Mustermann error hierarchy and exception types raised for malformed pattern syntax, invalid capture identifiers, anchored regexps, unsupported types, and missing expand parameters
Amostra verificada para gem mustermann 4.0.0: Distinguish Mustermann error hierarchy and exception types raised for malformed pattern syntax, invalid capture…
sha256:aaa0dba8bc057cb87c4fc9aba644a736d975024736c643655c77f03ab87944e3
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 2
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
ruby linux x64 ruby ruby rubygems
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| ruby 3 · linux alpine/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · rubygems@1 |
2026-08-16 |
| ruby 3 · linux debian/x64 · docker ed25519:2175b912ea1c23b1 | SKIPPED | compile:SKIPPED · contract:SKIPPED · load:SKIPPED · resolve:FAIL CONTAINER_RUN · rubygems@1 |
2026-08-18 |
Caso
HOW- Objetivo
- Distinguish Mustermann error hierarchy and exception types raised for malformed pattern syntax, invalid capture identifiers, anchored regexps, unsupported types, and missing expand parameters
- Pacotes
- Símbolos
-
- Mustermann.new
- Mustermann::Error
- Mustermann::CompileError
- Mustermann::ParseError
- Mustermann::ExpandError
- Mustermann::Pattern#expand
- Mustermann::Pattern#params
- Ambiente
- ruby
- Criado
- 2026-08-16T15:54:28Z
Contrato
- Mustermann raises Mustermann::CompileError rather than Mustermann::ParseError when a pattern contains malformed capture names such as empty captures or leading digits, while unclosed groupings raise Mustermann::ParseError and expand with :ignore still raises Mustermann::ExpandError when required keys are missing.
- assert Mustermann.new('/foo/:') and Mustermann.new('/foo/:123') raise Mustermann::CompileError instead of Mustermann::ParseError
- assert Mustermann.new('/foo/(bar') and Mustermann.new('/foo/{bar') raise Mustermann::ParseError with unexpected token messages
- assert Mustermann.new('^/foo', type: :regexp) raises Mustermann::CompileError when anchor characters are present in regular expressions
- assert Mustermann.new('/foo', type: :unsupported_custom_type) raises ArgumentError rather than Mustermann::Error
- assert pattern.expand(:ignore, {}) raises Mustermann::ExpandError when required captures are missing because :ignore only applies to extra keys
- assert pattern.expand(:invalid_behavior, id: 1) raises ArgumentError rather than Mustermann::ExpandError
- assert Mustermann::CompileError, Mustermann::ParseError, and Mustermann::ExpandError all inherit from Mustermann::Error < StandardError
Arquivos
- Gemfile
- NOTES.md
- csx.json
- test/contract.rb
Código-fonte
source "https://rubygems.org"
gem "mustermann", "4.0.0"
gem "minitest", "5.27.0"
# Mustermann Error Handling and Exception Boundaries
`search_known_solution` returned low-confidence compatible results pointing to unrelated crates and packages (`sha256:37c7408540f30c3e0ea78c7a69f7ddb967574c1c9fbfebcf11fbf25d3bbe07d5` for winnow error handling, `sha256:175897b84668b354a5c39ba16574961f62a504460d7259ed94746eae6b9bf866` for anyhow error downcasting, and `sha256:c4176f13ba0e8f85f39a4eab0dbbeb9630be1dd5d0d6d9d8d7223193eca43a14` for php-parser v5).
The wrong version fails loudly with an unhandled exception or failed assertion when assuming malformed capture names raise `Mustermann::ParseError` instead of `Mustermann::CompileError`, or when expecting `expand(:ignore, ...)` to suppress missing capture errors.
{"case":{"believed":"Malformed route pattern strings raise Mustermann::ParseError on invalid capture syntax, while :ignore expansion suppresses missing parameter errors.","caseId":"case:sha256:d6af2c1f26b14ed64630e83feaf7898f232c1612485fc7ea487d999dfb3222f2","contract":["Mustermann raises Mustermann::CompileError rather than Mustermann::ParseError when a pattern contains malformed capture names such as empty captures or leading digits, while unclosed groupings raise Mustermann::ParseError and expand with :ignore still raises Mustermann::ExpandError when required keys are missing.","assert Mustermann.new('/foo/:') and Mustermann.new('/foo/:123') raise Mustermann::CompileError instead of Mustermann::ParseError","assert Mustermann.new('/foo/(bar') and Mustermann.new('/foo/{bar') raise Mustermann::ParseError with unexpected token messages","assert Mustermann.new('^/foo', type: :regexp) raises Mustermann::CompileError when anchor characters are present in regular expressions","assert Mustermann.new('/foo', type: :unsupported_custom_type) raises ArgumentError rather than Mustermann::Error","assert pattern.expand(:ignore, {}) raises Mustermann::ExpandError when required captures are missing because :ignore only applies to extra keys","assert pattern.expand(:invalid_behavior, id: 1) raises ArgumentError rather than Mustermann::ExpandError","assert Mustermann::CompileError, Mustermann::ParseError, and Mustermann::ExpandError all inherit from Mustermann::Error \u003c StandardError"],"goal":"Distinguish Mustermann error hierarchy and exception types raised for malformed pattern syntax, invalid capture identifiers, anchored regexps, unsupported types, and missing expand parameters","kind":"HOW","packages":["pkg:gem/mustermann@4.0.0"],"schemaVersion":1,"symbols":["Mustermann.new","Mustermann::Error","Mustermann::CompileError","Mustermann::ParseError","Mustermann::ExpandError","Mustermann::Pattern#expand","Mustermann::Pattern#params"]},"contractCommand":["ruby","test/contract.rb"],"environment":{"arch":"x64","ecosystem":"gem","executionContext":"ruby","language":"ruby","os":"linux","packageManager":"rubygems","runtime":"ruby","schemaVersion":1},"license":"MIT-0","packages":["pkg:gem/mustermann@4.0.0"],"schemaVersion":1,"symbols":["Mustermann.new","Mustermann::Error","Mustermann::CompileError","Mustermann::ParseError","Mustermann::ExpandError","Mustermann::Pattern#expand","Mustermann::Pattern#params"],"verifierAdapter":"rubygems@1"}
# frozen_string_literal: true
require 'minitest/autorun'
require 'mustermann'
class MustermannErrorHandlingContractTest < Minitest::Test
def test_error_hierarchy_inherits_from_mustermann_error_and_standard_error
assert_operator Mustermann::Error, :<, StandardError
assert_operator Mustermann::CompileError, :<, Mustermann::Error
assert_operator Mustermann::ParseError, :<, Mustermann::Error
assert_operator Mustermann::ExpandError, :<, Mustermann::Error
assert_operator Mustermann::TrieError, :<, Mustermann::CompileError
end
def test_malformed_capture_names_raise_compile_error_rather_than_parse_error
# Empty capture name (/:) raises CompileError, not ParseError
empty_err = assert_raises(Mustermann::CompileError) do
Mustermann.new('/foo/:')
end
assert_includes empty_err.message, "capture name can't be empty"
refute empty_err.is_a?(Mustermann::ParseError)
# Invalid capture name starting with digit (/:123) raises CompileError, not ParseError
digit_err = assert_raises(Mustermann::CompileError) do
Mustermann.new('/foo/:123')
end
assert_includes digit_err.message, "capture name must start with underscore or lower case letter"
refute digit_err.is_a?(Mustermann::ParseError)
# Forbidden capture name in named splat (/*captures) raises CompileError
splat_err = assert_raises(Mustermann::CompileError) do
Mustermann.new('/foo/*captures')
end
assert_includes splat_err.message, "capture name can't be captures"
refute splat_err.is_a?(Mustermann::ParseError)
end
def test_unclosed_groups_and_brackets_raise_parse_error
# Unclosed parentheses
paren_err = assert_raises(Mustermann::ParseError) do
Mustermann.new('/foo/(bar')
end
assert_includes paren_err.message, 'unexpected end of string while parsing'
# Unclosed braces
brace_err = assert_raises(Mustermann::ParseError) do
Mustermann.new('/foo/{bar')
end
assert_includes brace_err.message, 'unexpected end of string while parsing'
# Trailing escape backslash
escape_err = assert_raises(Mustermann::ParseError) do
Mustermann.new('/foo\\')
end
assert_includes escape_err.message, 'unexpected end of string while parsing'
end
def test_anchor_in_regexp_pattern_raises_compile_error
anchor_err = assert_raises(Mustermann::CompileError) do
Mustermann.new('^/foo', type: :regexp)
end
assert_includes anchor_err.message, 'regular expression should not contain ^'
end
def test_unsupported_pattern_type_raises_argument_error_not_mustermann_error
arg_err = assert_raises(ArgumentError) do
Mustermann.new('/foo', type: :unsupported_custom_type)
end
assert_includes arg_err.message, 'unsupported type :unsupported_custom_type'
refute arg_err.is_a?(Mustermann::Error)
end
def test_expand_missing_required_keys_raises_expand_error_even_with_ignore_behavior
pattern = Mustermann.new('/users/:id')
# Missing required keys raise ExpandError across all behaviors
assert_raises(Mustermann::ExpandError) do
pattern.expand(:raise, {})
end
assert_raises(Mustermann::ExpandError) do
pattern.expand(:ignore, {})
end
assert_raises(Mustermann::ExpandError) do
pattern.expand(:append, {})
end
# Extra keys: :raise fails, :ignore drops, :append adds query params
raise_err = assert_raises(Mustermann::ExpandError) do
pattern.expand(:raise, id: 10, extra: 'val')
end
assert_includes raise_err.message, 'cannot expand with keys'
assert_equal '/users/10', pattern.expand(:ignore, id: 10, extra: 'val')
assert_equal '/users/10?extra=val', pattern.expand(:append, id: 10, extra: 'val')
# Unknown expand behavior raises ArgumentError, not ExpandError
behavior_err = assert_raises(ArgumentError) do
pattern.expand(:invalid_behavior, id: 10)
end
assert_includes behavior_err.message, 'unknown behavior :invalid_behavior'
refute behavior_err.is_a?(Mustermann::ExpandError)
end
def test_non_matching_and_invalid_param_inputs
pattern = Mustermann.new('/users/:id')
# Non-matching path returns nil for params and false for ===
assert_nil pattern.params('/other/path')
refute pattern === '/other/path'
# Non-string input to params raises TypeError
assert_raises(TypeError) do
pattern.params(12345)
end
end
end