pact-foundation / pact-reference

Reference implementations for the pact specifications
https://pact.io
MIT License
91 stars 46 forks source link

"Iterator past the end ..." panics #344

Closed tienvx closed 4 months ago

tienvx commented 7 months ago

I got these panics while working with message's iterators:

Caught panic with error: iter past the end of metadata with:

and Caught panic with error: iter past the end of messages with:

It's not a problem at least on PHP on normal condition, because the code is still running:

Feature: Message consumer
  Supports V3 message consumer interactions

  Scenario: Supports the use of generators with message metadata                   # compatibility-suite/pact-compatibility-suite/features/V3/message_consumer.feature:71
    Given a message integration is being defined for a consumer test               # PhpPactTest\CompatibilitySuite\Context\V3\Message\ConsumerContext::aMessageIntegrationIsBeingDefinedForAConsumerTest()
    And the message is configured with the following:                              # PhpPactTest\CompatibilitySuite\Context\V3\Message\ConsumerContext::theMessageIsConfiguredWithTheFollowing()
      | generators                                                                      | metadata                                  |
      | JSON: { "metadata": { "ID": { "type": "RandomInt", "min": 0,  "max": 1000 } } } | { "ID": "sjhdjkshsdjh", "weight": 100.5 } |
Caught panic with error: iter past the end of metadata
Caught panic with error: iter past the end of messages
Caught panic with error: iter past the end of messages
Caught panic with error: iter past the end of messages
Caught panic with error: iter past the end of messages
Caught panic with error: iter past the end of messages
    When the message is successfully processed                                     # PhpPactTest\CompatibilitySuite\Context\V3\Message\ConsumerContext::theMessageIsSuccessfullyProcessed()
    Then the received message metadata will contain "weight" == "JSON: 100.5"      # PhpPactTest\CompatibilitySuite\Context\V3\Message\ConsumerContext::theReceivedMessageMetadataWillContain()
    And the received message metadata will contain "ID" replaced with an "integer" # PhpPactTest\CompatibilitySuite\Context\V3\Message\ConsumerContext::theReceivedMessageMetadataWillContainReplacedWithAn()

1 scenario (1 passed)
5 steps (5 passed)
0m0.05s (13.76Mb)

But when I start debugging in PHP using XDebug, the code stop working:

@message
Feature: Message consumer
  Supports V3 message consumer interactions

  Scenario: Supports the use of generators with message metadata                   # compatibility-suite/pact-compatibility-suite/features/V3/message_consumer.feature:71
    Given a message integration is being defined for a consumer test               # PhpPactTest\CompatibilitySuite\Context\V3\Message\ConsumerContext::aMessageIntegrationIsBeingDefinedForAConsumerTest()
    And the message is configured with the following:                              # PhpPactTest\CompatibilitySuite\Context\V3\Message\ConsumerContext::theMessageIsConfiguredWithTheFollowing()
      | generators                                                                      | metadata                                  |
      | JSON: { "metadata": { "ID": { "type": "RandomInt", "min": 0,  "max": 1000 } } } | { "ID": "sjhdjkshsdjh", "weight": 100.5 } |
fish: Job 1, 'vendor/bin/behat compatibility-…' terminated by signal SIGSEGV (Address boundary error)
rholshausen commented 7 months ago

Hmm, printing that panic message is not helpful. It does that when it gets to the end of the iteration.