Skip to content

Bug: Plugins are "ignored" when provider name is variable #4837

Closed

Description

@MacMcIrish

This is a Bug Report

Description

When the provider name is a variable, the proper plugin may not be used.

For bug reports:

  • What went wrong?
    The loaded deploy plugin was lib/plugins/deploy.
  • What did you expect should have happened?
    The loaded deploy plugin to be lib/plugins/aws/common/deploy
  • What was the config you used?
---
custom:
  name: aws

provider:
  name: ${self:custom.name}
---

Similar or dependent issues:

Additional Data

I've noticed in PluginManager, the following snippet:

    // ignore plugins that specify a different provider than the current one
    if (pluginProvider
      && (pluginProvider !== this.serverless.service.provider.name)) {
      return;
    }

The issue is the provider variables have not been loaded by this step, so I'm assuming the aws plugins are then ignored?

  • Serverless Framework Version you're using:
    1.26.0 (master branch at time of posting)
  • Operating System:
    Ubuntu 16.04

Activity

  1. erikerikson commented on Mar 19, 2018

    @erikerikson
    Contributor

    Yes, the filtering of plugins in PluginManager combines with the fact that plugins are loaded in init whereas the service is populated in run and init is called before run.

    This definitely represents a hidden dissonance with the mental model of engineers in using variables within serverless.[json||yml||yaml] and the returned content of serverless.js. One challenge of not doing things in this order is that the proper population of a service can depend upon the provider that the service targets. Not sure whether this one should be marked as a "bug" as "working as expected".

  2. MacMcIrish commented on Mar 25, 2018

    @MacMcIrish
    ContributorAuthor

    @erikerikson Thanks for replying. I think the misunderstanding comes from how the second example for serverless variables uses the provider as the target, it's not really clear that the provider name has any kind of restriction on it, or any of the provider variables really.

    If it's hard baked into the design to not support variables for this provider.name, would it make sense to include a warning in the docs that the provider name cannot be a variable?

  3. erikerikson commented on Mar 25, 2018

    @erikerikson
    Contributor

    That at least seems a reasonable short term mitigation.

    I think there's a long term argument for provider being legacy that disappears. Particularly for the rare but important cross provider use cases.

    Given the declaration of plugins in serverless.yml, it could seem that the resolution order is somewhat backwards. That said, it's certainly legacy and the way of it for the time being. Switching would also have the potential impact of disallowing plugin's involvement in variable resolution which is desirable for a few rather sticky scenarios involving conflicts.

  4. medikoo commented on Mar 3, 2021

    @medikoo
    Contributor

    Fixed with #8987

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions