fix(codegen): parse recapitalised Array-of return sentence

Telegram rewrote the forwardMessages and copyMessages return sentence from
"an array of MessageId" to "an Array of MessageId". The pattern that handles
the "... of the sent messages is returned" shape matched lowercase only, so
both methods fell back to bool and the weekly regen job failed at the audit
step.

Add approved_any_locations to overrides.json so a union that renders as `any`
by design can be approved as data instead of a code change. Approve
InputRichMessageMedia.Media, a five-variant InputMedia union added in Bot
API 10.2 that has no declared parent type.

Make the drift test compare HEAD against itself. It compared the working tree
against HEAD, so it failed whenever a regen run added a method.
This commit is contained in:
2026-07-21 22:52:06 +01:00
parent cd05e6a426
commit 5aabbe6151
7 changed files with 75 additions and 17 deletions
+7 -6
View File
@@ -54,7 +54,7 @@ func main() {
var problems []string
problems = append(problems, auditBool(api, overrides)...)
problems = append(problems, auditAny(api)...)
problems = append(problems, auditAny(api, overrides)...)
driftFound := false
if *checkDrift {
@@ -140,8 +140,9 @@ func looksGenuinelyBool(doc string) bool {
// auditAny scans the IR for any KindOneOf TypeRef that would render as
// `any` in generated code (not matched by ChatID/InputFile-or-string/known
// union heuristics). Reports each occurrence with location.
func auditAny(api *spec.API) []string {
// union heuristics). Reports each occurrence with location, except the
// locations approved in overrides.
func auditAny(api *spec.API, ov *spec.Overrides) []string {
var out []string
isKnownUnion := func(variants []string) bool {
if hasVariants(variants, "int64", "string") {
@@ -166,17 +167,17 @@ func auditAny(api *spec.API) []string {
}
for _, t := range api.Types {
for _, f := range t.Fields {
if isAny(f.Type) {
if isAny(f.Type) && !ov.IsAnyApproved(t.Name+"."+f.Name) {
out = append(out, fmt.Sprintf("any field: %s.%s (variants=%v)", t.Name, f.Name, f.Type.Variants))
}
}
}
for _, m := range api.Methods {
if isAny(m.Returns) {
if isAny(m.Returns) && !ov.IsAnyApproved(m.Name) {
out = append(out, fmt.Sprintf("any return: %s (variants=%v)", m.Name, m.Returns.Variants))
}
for _, p := range m.Params {
if isAny(p.Type) {
if isAny(p.Type) && !ov.IsAnyApproved(m.Name+"."+p.Name) {
out = append(out, fmt.Sprintf("any param: %s.%s (variants=%v)", m.Name, p.Name, p.Type.Variants))
}
}