mirror of
https://github.com/larksuite/cli.git
synced 2026-09-14 18:42:53 +08:00
20ef0af8a7
* fix(event): preserve UTF-8 in truncated diagnostics * test(event): preserve preflight decode cause coverage
25 lines
817 B
Go
25 lines
817 B
Go
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package event
|
|
|
|
import (
|
|
"fmt"
|
|
"regexp"
|
|
|
|
eventlib "github.com/larksuite/cli/internal/event"
|
|
)
|
|
|
|
// authURLPattern matches the grant-scope URL embedded in 99991672 errors; widen the host alternation when adding brands.
|
|
var authURLPattern = regexp.MustCompile(`https?://open\.(?:feishu\.cn|larksuite\.com)/app/[^/\s"']+/auth\?q=[^\s"'<>]+`)
|
|
|
|
// describeAppMetaErr reduces a FetchCurrentPublished error to a one-line stderr summary.
|
|
func describeAppMetaErr(err error) string {
|
|
msg := err.Error()
|
|
if url := authURLPattern.FindString(msg); url != "" {
|
|
return fmt.Sprintf("bot is missing scopes needed for app-version metadata; grant at: %s", url)
|
|
}
|
|
const maxErrLen = 200
|
|
return eventlib.TruncateDiagnostic(msg, maxErrLen, "…")
|
|
}
|