【问题标题】:GCP Secret Manager throws: "path" argument must be of type stringGCP Secret Manager 抛出:“路径”参数必须是字符串类型
【发布时间】:2020-08-02 05:23:51
【问题描述】:

我正在使用 Node.js 8.x 中的 GCP Secrets Manager(我知道,它很古老,但它是 Cloud Functions 上最新的 GA Node 运行时)。但是,当我运行他们的示例时,它不断从this line 抛出 gRPC 错误:

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type object

我正在尝试测试的代码行:

const secretClient = new SecretManagerServiceClient();

如果我在节点 8.x 或节点 10.x 上运行,并且如果我使用最新版本的机密库 (3.0.0) 或节点 8.x 的旧版本 ( 1.2.1)

【问题讨论】:

    标签: node.js google-cloud-platform google-secret-manager


    【解决方案1】:

    出现这个错误是因为库运行的是 browser 而不是 Node 模式,这迫使它避免“回退”模式,试图错误地查找 gRPC 路径.该决定是因为window 在范围内,欺骗了isBrowser logic

    根本原因

    根本原因是jest被用于测试,由default runs in jsDom mode,插入像window这样的全局变量。

    修复

    将以下内容添加到您的 jest.config.json 文件中。

    testEnvironment: 'node',
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-08-12
      • 2020-10-21
      • 2021-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-13
      相关资源
      最近更新 更多