You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
后者的注释写着「canonical buckets per industry convention (Salesforce, Power Platform, ServiceNow all use this taxonomy)」,即它自认是这个分类法的正本。前者是后者的真子集,两者之间没有任何引用关系,也没有任何东西保证它们同步演进。
发现于 #4828 的实施(界外发现,查重无命中故新开;未认领;observation-class)。
现象
packages/spec里有两个枚举描述同一个概念:DiscoverySchema.environmentsrc/api/discovery.zod.tsproduction、sandbox、developmentEnvironmentTypeSchemasrc/cloud/environment.zod.tsproduction、sandbox、development、test、staging、preview、trial后者的注释写着「canonical buckets per industry convention (Salesforce, Power Platform, ServiceNow all use this taxonomy)」,即它自认是这个分类法的正本。前者是后者的真子集,两者之间没有任何引用关系,也没有任何东西保证它们同步演进。
影响
#4828 因此必须引入一个有损映射:
NODE_ENV=staging和test都是EnvironmentTypeSchema里的一等成员,但在 discovery 面上必须被折叠进 3 个桶(staging → sandbox、test → development)。这个映射本身是维护者裁定认可的(discovery 只需回答「我在不在生产」这种粗粒度问题),但「同一个词在两个 schema 里含义不同」这件事本身是漂移。具体的坑:一个读了
EnvironmentTypeSchema的作者会以为staging是合法的environment取值,而DiscoverySchema会拒绝它(discovery.test.ts里就有一条should reject invalid environment用的正是'staging')。可能的处置
DiscoverySchema.environment的.describe()里点名EnvironmentTypeSchema是更细的分类法(两个 discovery 生产者都在线上返回 schema 未声明的顶层字段(scoping / features / endpoints),且 REST 形状永远无法通过 DiscoverySchema #4828 已经加了这句),并在EnvironmentTypeSchema那边回指;再加一条测试钉住「discovery 的 3 个成员是 EnvironmentType 的子集」,这样后者改名/删成员时前者会红。EnvironmentTypeSchema:去掉有损映射,但这会放宽一个响应枚举 —— 对按 3 个值做 switch 的消费者是前向不兼容的。两个 discovery 生产者都在线上返回 schema 未声明的顶层字段(scoping / features / endpoints),且 REST 形状永远无法通过 DiscoverySchema #4828 的裁定明确要求生产者取值落在 3 成员枚举内,所以这条需要新的裁定才能走。选 1 的话是小活;选 2 是契约变更。倾向 1 + 那条子集测试:成本极低,而且能把「两个枚举」从沉默的漂移变成有闸门看着的关系。
参考:#4828(引入了映射函数
resolveDiscoveryEnvironment与映射表)。