Skip to content

import --watch ignores --config on file changes and can upload to the wrong server #628

Open

Description

@Syedowais312

Describe the bug

When using import --watch with a custom --config, the initial import uses the specified configuration, but subsequent imports triggered by file changes use the default configuration.

If both configurations contain the same context name pointing to different servers, updates are uploaded to a different server from the initial import.

Expected behavior

The initial import and all subsequent watched imports should resolve the context using the configuration selected with --config.

Actual behavior

The initial import uses the selected configuration. Watched imports resolve the same context name using the default configuration and therefore upload to the other server.

How to Reproduce?

  1. Start two local Microcks instances:

    ./microcks start --name repro-dev --port 8585
    ./microcks start --name repro-other --port 8586
    
  2. Prepare two configurations with a context named team, and set current-context: team in both:

    Config file Context Server
    /tmp/microcks-dev.yml team http://localhost:8585
    ~/.config/microcks/config team http://localhost:8586

    Each context should reference the corresponding server and user entries in its own configuration.

  3. Create microcks-repro-api.yml:

    openapi: 3.0.0
    info:
      title: Watch Config Demo
      version: '1.0'
    paths:
      /hello:
        get:
          operationId: sayHello
          responses:
            '200':
              description: Successful response
              content:
                application/json:
                  example:
                    message: Hello
    
  4. Import the file using the custom configuration and enable watching:

    ./microcks --config /tmp/microcks-dev.yml \
      import ./microcks-repro-api.yml --watch
    
  5. Confirm that Watch Config Demo version 1.0 appears on http://localhost:8585.

  6. Change the YAML version to '2.0' and save the file.

  7. Check both Microcks instances. Version 2.0 appears on http://localhost:8586, although the command explicitly selected the configuration pointing to port 8585

Microcks version or git rev

No response

Install method (docker-compose, helm chart, operator, docker-desktop extension,...)

No response

Additional information

No response

Activity

  1. Syedowais312 commented on Nov 13, 2026

    @Syedowais312
    ContributorAuthor

    CC @Harsh4902 @Caesarsage

    The fix would be to save the selected --config path in the watch entry and reuse it for subsequent imports instead of loading the default config.

    If you confirm this bug and the approach looks good, I can open a PR with the fix.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions