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

[v1.x] - Sales Channels feature is mandatory when retrieving a Product on the Admin API Route ? #8102

Closed
adevinwild opened this issue Jul 12, 2024 · 3 comments

Comments

@adevinwild
Copy link
Contributor

Bug report

Describe the bug

When you disable the sales_channel feature flag, you keep getting errors on the [GET] - /admin/products/:id route.
It's because that route still tries to look for product's sales channels, I remember that at a time a check was made using the FF router, but now it seems that it's always there :

// [v1.20.7] - src/api/routes/admin/products/get-product.ts

const shouldSetAvailability =
    req.retrieveConfig.relations?.includes("variants")

  if (shouldSetAvailability) {
    let salesChannels

    if (isMedusaV2FlagOn) {
      const remoteQuery = req.scope.resolve("remoteQuery")
      const query = {
        sales_channel: {
          fields: ["id"],
        },
      }
      salesChannels = await remoteQuery(query)
    } else {
      const salesChannelService: SalesChannelService = req.scope.resolve(
        "salesChannelService"
      )
      ;[salesChannels] = await salesChannelService.listAndCount(
        {},
        { select: ["id"] }
      )
    }

    decoratePromises.push(
      productVariantInventoryService.setProductAvailability(
        [product],
        salesChannels.map((salesChannel) => salesChannel.id)
      )
    )
  }

System information

Medusa version (including plugins): v1.20.7

Steps to reproduce the behavior

  1. Disable the sales_channel feature flag in the Medusa config
  2. Create a product on the Admin UI
  3. Error is throwed in the console :
driverError: error: relation "public.sales_channel" does not exist

Expected behavior

I expect a check with the FF router to check if the sales_channel feature flag is enabled to make sure we don't have this relation error.

@sradevski
Copy link
Member

@adevinwild hey thanks for the report! Would you be keen on opening a PR to fix this? Thanks!

@adevinwild
Copy link
Contributor Author

@adevinwild hey thanks for the report! Would you be keen on opening a PR to fix this? Thanks!

Yes!
Will fix this this weekend 🙌

@adevinwild
Copy link
Contributor Author

Here is the related PR 🙌
#8120

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

No branches or pull requests

2 participants