File tree Expand file tree Collapse file tree 2 files changed +34
-18
lines changed
Expand file tree Collapse file tree 2 files changed +34
-18
lines changed Original file line number Diff line number Diff line change @@ -328,24 +328,24 @@ describe("resolveFeishuAccount", () => {
328328 expect ( account . appId ) . toBe ( "cli_default" ) ;
329329 } ) ;
330330
331- it ( "surfaces unresolved SecretRef errors in account resolution" , ( ) => {
332- expect ( ( ) =>
333- resolveFeishuAccount ( {
334- cfg : {
335- channels : {
336- feishu : {
337- accounts : {
338- main : {
339- appId : "cli_123" ,
340- appSecret : { source : "file" , provider : "default" , id : "path/to/secret" } ,
341- } as never ,
342- } ,
331+ it ( "treats unresolved SecretRef as not configured in account resolution" , ( ) => {
332+ const account = resolveFeishuAccount ( {
333+ cfg : {
334+ channels : {
335+ feishu : {
336+ accounts : {
337+ main : {
338+ appId : "cli_123" ,
339+ appSecret : { source : "file" , provider : "default" , id : "path/to/secret" } ,
340+ } as never ,
343341 } ,
344342 } ,
345- } as never ,
346- accountId : "main" ,
347- } ) ,
348- ) . toThrow ( / u n r e s o l v e d S e c r e t R e f / i) ;
343+ } ,
344+ } as never ,
345+ accountId : "main" ,
346+ } ) ;
347+ expect ( account . configured ) . toBe ( false ) ;
348+ expect ( account . appSecret ) . toBeUndefined ( ) ;
349349 } ) ;
350350
351351 it ( "does not throw when account name is non-string" , ( ) => {
Original file line number Diff line number Diff line change @@ -25,6 +25,13 @@ const {
2525
2626export { listFeishuAccountIds } ;
2727
28+ function isUnresolvedSecretRefError ( error : unknown ) : boolean {
29+ if ( ! ( error instanceof Error ) ) {
30+ return false ;
31+ }
32+ return / u n r e s o l v e d S e c r e t R e f / i. test ( error . message ) ;
33+ }
34+
2835/**
2936 * Resolve the default account selection and its source.
3037 */
@@ -191,8 +198,17 @@ export function resolveFeishuAccount(params: {
191198 const accountEnabled = merged . enabled !== false ;
192199 const enabled = baseEnabled && accountEnabled ;
193200
194- // Resolve credentials from merged config
195- const creds = resolveFeishuCredentials ( merged ) ;
201+ // Resolve credentials from merged config.
202+ // CLI startup can parse config before gateway-backed SecretRef resolution is available.
203+ // Treat unresolved refs as "not configured" here instead of crashing plugin load.
204+ let creds : ReturnType < typeof resolveFeishuCredentials > = null ;
205+ try {
206+ creds = resolveFeishuCredentials ( merged ) ;
207+ } catch ( error ) {
208+ if ( ! isUnresolvedSecretRefError ( error ) ) {
209+ throw error ;
210+ }
211+ }
196212 const accountName = ( merged as FeishuAccountConfig ) . name ;
197213
198214 return {
You can’t perform that action at this time.
0 commit comments