Skip to content

Conversation

othorizon
Copy link
Contributor

variable_defs这个数组服务器可能没返回导致buildVariableMap 中直接 for遍历这个对象时报错。
这可能不是一个最佳性能的修复方式,但是保证了最小代码修改和尽可能好的可阅读性。

function buildVariableMap(variableDefs, variables) {
  const variableMap = {};
  const variableKeys = new Set(Object.keys(variables || {}));
  for (const def of variableDefs) {
    if (!variableKeys.has(def.key)) {
      continue;
    }
    variableMap[def.key] = {
      def,
      value: variables?.[def.key]
    };
  }
  return variableMap;
}

@CLAassistant
Copy link

CLAassistant commented Jul 31, 2025

CLA assistant check
All committers have signed the CLA.

@mocayo
Copy link
Collaborator

mocayo commented Jul 31, 2025

lgtm, thanks for your work

Copy link

codecov bot commented Jul 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@           Coverage Diff           @@
##             main      #11   +/-   ##
=======================================
  Coverage   88.60%   88.60%           
=======================================
  Files          57       57           
  Lines        3000     3000           
  Branches      632      632           
=======================================
  Hits         2658     2658           
+ Misses        342      341    -1     
- Partials        0        1    +1     
Components Coverage Δ
@cozeloop/ai 91.53% <100.00%> (ø)
@cozeloop/langchain 82.76% <ø> (ø)
Files with missing lines Coverage Δ
packages/cozeloop-ai/src/prompt/utils.ts 99.01% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mocayo
Copy link
Collaborator

mocayo commented Jul 31, 2025

please edit your pr title to match our check, see git history for reference

@othorizon othorizon changed the title fix: variable_defs may be undefined fix(sdk): variable_defs may be undefined Jul 31, 2025
@othorizon othorizon changed the title fix(sdk): variable_defs may be undefined build: fix variable_defs may be undefined Jul 31, 2025
@othorizon othorizon changed the title build: fix variable_defs may be undefined [fix] variable_defs may be undefined Jul 31, 2025
@mocayo
Copy link
Collaborator

mocayo commented Jul 31, 2025

please edit your pr title to match our check, see git history for reference

[fix] [sdk] variable_defs may be undefined

@othorizon othorizon changed the title [fix] variable_defs may be undefined [fix] [sdk] variable_defs may be undefined Jul 31, 2025
@mocayo mocayo merged commit fb0c689 into coze-dev:main Jul 31, 2025
12 of 15 checks passed
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 this pull request may close these issues.

3 participants