resolveForeignCommitID attempts to recover the module identity for a commit_id this proxy never minted (e.g. one a buf CLI client cached from a different registry). It is called by ServeDownload when commitMap lookup misses, before falling back to a 400. Resolution strategy: 1. If infoCache has ex
(commitID string)
| 830 | // |
| 831 | // Returns nil when the module identity cannot be recovered. |
| 832 | func (h *commitServiceHandler) resolveForeignCommitID(commitID string) *moduleRef { |
| 833 | if commitID == "" { |
| 834 | return nil |
| 835 | } |
| 836 | h.commitMu.Lock() |
| 837 | defer h.commitMu.Unlock() |
| 838 | if len(h.infoCache) != 1 { |
| 839 | return nil |
| 840 | } |
| 841 | for key, info := range h.infoCache { |
| 842 | // Reject if the cached entry is for an id that does not match: this |
| 843 | // happens when the single entry itself is for a *different* foreign |
| 844 | // id we previously aliased. We trust the entry's commitID only as a |
| 845 | // resolved-id hint, not as an equality check — the whole point of the |
| 846 | // fallback is that commitID differs from info.commitID. |
| 847 | owner, module, ok := splitOwnerModule(key) |
| 848 | if !ok { |
| 849 | return nil |
| 850 | } |
| 851 | ref := moduleRef{owner: owner, module: module} |
| 852 | // Register the foreign id as an alias of this module's ref so future |
| 853 | // requests for the same foreign id skip the fallback entirely. |
| 854 | h.commitMap[commitID] = ref |
| 855 | // Keep ownerID/moduleID consistent: also alias info.commitID -> ref |
| 856 | // is already present (set when the entry was written); nothing to do. |
| 857 | _ = info |
| 858 | return &ref |
| 859 | } |
| 860 | return nil |
| 861 | } |
| 862 | |
| 863 | // registerResolved records a resolved module for a commit id (the canonical |
| 864 | // git sha) under commitMu. commitMap[sha]=ref lets future Downloads of the |
no test coverage detected