Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation message of "migrate your config to use packages" persists even after migration #895

Closed
1 of 5 tasks
ravsii opened this issue Jan 14, 2025 · 2 comments · Fixed by #897
Closed
1 of 5 tasks

Comments

@ravsii
Copy link

ravsii commented Jan 14, 2025

Description

As guide says, I've migrated to using top-level .mockery.yaml file with packages map, but I'm still seeing these logs

14 Jan 25 12:31 MSK WRN DEPRECATION: use of the packages config will be the only way to generate mocks in v3. Please migrate your config to use the packages feature. deprecation-name=packages
 migration=https://vektra.github.io/mockery/v2.51/migrating_to_packages/ url=https://vektra.github.io/mockery/v2.51/features/#packages-configuration version=v2.51.0

The mocks are generated as expected

Mockery Version

v2.51.0

Go Version

go version go1.23.4 darwin/arm64

Installation Method

  • Binary Distribution
  • Docker
  • brew
  • go install
  • Other: [specify]

Steps to Reproduce

I had to cover some stuff since it's a private repo, but can try to provide a minimal reproducible example later.

  1. Create .mockery.yaml at the root of the project
with-expecter: True
all: False
inpackage: False
resolve-type-alias: False
issue-845-fix: True # https://vektra.github.io/mockery/latest/deprecations/#issue-845-fix

packages:
  <repo>/internal/handlers/<package>:
    interfaces:
      <interfaceName>:

repo is using gitlab.company.com/project/repo-name pattern

  1. $ mockery from root of the project

Expected Behavior

Mocks are being created without any error messages

Actual Behavior

14 Jan 25 12:13 MSK INF Starting mockery dry-run=false version=v2.51.0
14 Jan 25 12:13 MSK INF Using config: <repo>/.mockery.yaml dry-run=false version=v2.51.0
14 Jan 25 12:13 MSK INF done loading, visiting interface nodes dry-run=false version=v2.51.0
14 Jan 25 12:13 MSK INF generating mocks for interface dry-run=false interface=<interfaceName> qualified-name=<repo>/internal/handlers/<package> version=v2.51.0
14 Jan 25 12:13 MSK INF writing to file dry-run=false file=mocks/<repo>/internal/handlers/<package>/mock_<interfaceName>.go interface=
<interfaceName> qualified-name=<repo>/internal/handlers/<package> version=v2.51.0
14 Jan 25 12:13 MSK WRN DEPRECATION: use of the packages config will be the only way to generate mocks in v3. Please migrate your config to use the packages feature. deprecation-name=packages
 migration=https://vektra.github.io/mockery/v2.51/migrating_to_packages/ url=https://vektra.github.io/mockery/v2.51/features/#packages-configuration version=v2.51.0

After playing with different options for a while, it seems like missing config map under package cause this, because this config works fine and doesn't produce any errors

# opts from previous example

packages:
  <repo>/internal/handlers/<package>:
    config:
      recursive: True
    interfaces:
      <interfaceName>:

but having config: as an empty map crashes mockery

# opts from previous example

packages:
  <repo>/internal/handlers/<package>:
    config:
    interfaces:
      <interfaceName>:
trace
panic: interface conversion: interface {} is nil, not map[string]interface {}

goroutine 1 [running]:
github.com/vektra/mockery/v2/pkg/config.(*Config).addSubPkgConfig(0x14000118800, {0x10090a2b8, 0x140002885d0}, {0x14000030120, 0x5a}, {0x140000d82a0, 0x5a})
        /Users/aglazunov/go/pkg/mod/github.com/vektra/mockery/v2@v2.51.0/pkg/config/config.go:505 +0x858
github.com/vektra/mockery/v2/pkg/config.(*Config).discoverRecursivePackages(0x14000118800, {0x10090a2b8, 0x14000166e70})
        /Users/aglazunov/go/pkg/mod/github.com/vektra/mockery/v2@v2.51.0/pkg/config/config.go:631 +0xb08
github.com/vektra/mockery/v2/pkg/config.(*Config).Initialize(0x14000118800, {0x10090a2b8, 0x14000166e70})
        /Users/aglazunov/go/pkg/mod/github.com/vektra/mockery/v2@v2.51.0/pkg/config/config.go:127 +0x44
github.com/vektra/mockery/v2/cmd.(*RootApp).Run(0x14000118800)
        /Users/aglazunov/go/pkg/mod/github.com/vektra/mockery/v2@v2.51.0/cmd/mockery.go:208 +0x460
github.com/vektra/mockery/v2/cmd.NewRootCmd.func1(0x14000116e00?, {0x100729b45?, 0x4?, 0x100729b49?})
        /Users/aglazunov/go/pkg/mod/github.com/vektra/mockery/v2@v2.51.0/cmd/mockery.go:45 +0x48
github.com/spf13/cobra.(*Command).execute(0x1400012e908, {0x140000a0010, 0x0, 0x0})
        /Users/aglazunov/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:920 +0x630
github.com/spf13/cobra.(*Command).ExecuteC(0x1400012e908)
        /Users/aglazunov/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:1044 +0x320
github.com/spf13/cobra.(*Command).Execute(...)
        /Users/aglazunov/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:968
github.com/vektra/mockery/v2/cmd.Execute()
        /Users/aglazunov/go/pkg/mod/github.com/vektra/mockery/v2@v2.51.0/cmd/mockery.go:105 +0x20
main.main()
        /Users/aglazunov/go/pkg/mod/github.com/vektra/mockery/v2@v2.51.0/main.go:8 +0x1c

I have no need in changing any config options so I don't want to pass it explicitly. I also haven't found anything in the docs mentioning mandatory config map, so seems like a bug to me.

@LandonTClipp
Copy link
Collaborator

Sorry for the issue. This looks like a bug, I'll take a look. This might be related to the rework I did around deprecation warnings.

@LandonTClipp
Copy link
Collaborator

LandonTClipp commented Jan 20, 2025

This was just a weird edge case in my shitty config logic (which was totally redone in v3 btw, so don't hate me 😄 ). I submitted a PR that fixes this. Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants