Skip to content

[bug]: Next test-set ID incorrectly uses numeric suffix from custom metadata names #4377

Description

@sYanXO

Problem Summary

When a test-set is recorded with custom metadata ending in a number, that number incorrectly influences the next auto-generated test-set-N ID, causing it to skip ahead unexpectedly.

Example

Code:

pkg.NextID([]string{"test-set-0", "checkout-flow-999"}, "test-set-")

Expected Output:

test-set-1

Actual Output:

test-set-1000

Why This Happens

The allocator extracts numeric suffixes from all strings in the input list, not just those matching the requested prefix. When it encounters checkout-flow-999, it treats 999 as a candidate ID for the test-set- sequence, causing the next ID to incorrectly jump to 1000.

User-Level Impact

keploy record -c "<app cmd>" --metadata "name=checkout-flow-999"
keploy record -c "<app cmd>"

The second recording may create:

keploy/test-set-1000

Instead of the expected:

keploy/test-set-1

Root Cause

The ID parsing logic in pkg.NextID() and pkg.LastID() extracts numeric suffixes without first filtering by the requested prefix.

Affected Files

  • pkg/service/record/record.go
  • pkg/util.go

Likely Fix Area

  • pkg.NextID() — Filter candidate IDs to only those starting with the provided prefix before extracting numeric suffixes
  • pkg.LastID() — Same parsing pattern; requires the same fix

Solution Approach

Modify the ID extraction logic to:

  1. Filter strings to match prefix + numeric pattern only
  2. Extract the numeric part from matching IDs
  3. Return the next sequential number

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions