Exemple
google.golang.org/grpc v1.82.0: codes.InvalidArgument
Échantillon vérifié pour golang google.golang.org/grpc v1.82.0: codes.InvalidArgument. Le contrat s'est exécuté sur go 1.26 · linux debian/x64 · docker et a…
sha256:84a1740c5f8aca819c3b6f2a6ba06bd36f3bb21a483793138753bcf55354eb11
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
go linux 24 · ubuntu · glibc 2.39 x64 go go go
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a… |
2026-10-12 |
Cas
HOW- Objectif
- verify google.golang.org/grpc/codes.InvalidArgument in pkg:golang/google.golang.org/grpc@v1.82.0
- Paquets
- Symboles
-
- google.golang.org/grpc/codes.InvalidArgument
- Environnement
- go
- Créé
- 2026-10-12T10:26:27Z
Contrat
- codes.InvalidArgument represents client-specified invalid argument with integer code 3 and string representation 'InvalidArgument'.
- codes.Code.UnmarshalJSON unmarshals string 'INVALID_ARGUMENT' and numeric 3 to codes.InvalidArgument.
- status.Error and status.FromError associate errors with codes.InvalidArgument, verifiable via status.Code.
Fichiers
- PROMPT.md
- csx.json
- go.mod
- go.sum
- sample.go
- spec.json
- test/contract_test.go
Code source
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify google.golang.org/grpc/codes.InvalidArgument in pkg:golang/google.golang.org/grpc@v1.82.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/google.golang.org/grpc@v1.82.0
Demonstrate these symbols/APIs:
- google.golang.org/grpc/codes.InvalidArgument
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:c73f1eb43f12484f4e21ff994afe05647142fccc5f82ffbf53a66dab097b8698","contract":["codes.InvalidArgument represents client-specified invalid argument with integer code 3 and string representation 'InvalidArgument'.","codes.Code.UnmarshalJSON unmarshals string 'INVALID_ARGUMENT' and numeric 3 to codes.InvalidArgument.","status.Error and status.FromError associate errors with codes.InvalidArgument, verifiable via status.Code."],"goal":"verify google.golang.org/grpc/codes.InvalidArgument in pkg:golang/google.golang.org/grpc@v1.82.0","kind":"HOW","packages":["pkg:golang/google.golang.org/grpc@v1.82.0"],"schemaVersion":1,"symbols":["google.golang.org/grpc/codes.InvalidArgument"]},"contractCommand":["go","test","./..."],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","language":"go","libc":"glibc","libcVersion":"2.39","moduleSystem":"go.mod","os":"linux","osVersionBucket":"24","packageManager":"go","runtime":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/google.golang.org/grpc@v1.82.0"],"schemaVersion":1,"subject":"pkg:golang/google.golang.org/grpc@v1.82.0","symbols":["google.golang.org/grpc/codes.InvalidArgument"],"verifierAdapter":"golang@1"}
module example.com/invalidargument
go 1.25.0
require google.golang.org/grpc v1.82.0
require (
golang.org/x/sys v0.43.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478 // indirect
google.golang.org/protobuf v1.36.11 // indirect
)
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
golang.org/x/net v0.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA=
golang.org/x/net v0.53.0/go.mod h1:JvMuJH7rrdiCfbeHoo3fCQU24Lf5JJwT9W3sJFulfgs=
golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=
golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg=
golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478 h1:RmoJA1ujG+/lRGNfUnOMfhCy5EipVMyvUE+KNbPbTlw=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
google.golang.org/grpc v1.82.0 h1:vguDnZUPjE26w09A63VoxZPnvPjB5Riyc0mkXPFmAIU=
google.golang.org/grpc v1.82.0/go.mod h1:yzTZ1TB1Z3SG+LIYaI+WiE8D5+PZ3ArnrSp8zF3+/ZA=
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
package invalidargument
import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
// IsInvalidArgument reports whether err has gRPC status code InvalidArgument.
func IsInvalidArgument(err error) bool {
return status.Code(err) == codes.InvalidArgument
}
// NewInvalidArgumentError creates a gRPC error with status code InvalidArgument.
func NewInvalidArgumentError(msg string) error {
return status.Error(codes.InvalidArgument, msg)
}
// InvalidArgumentCode returns the codes.InvalidArgument constant.
func InvalidArgumentCode() codes.Code {
return codes.InvalidArgument
}
{
"schemaVersion": 1,
"goal": "verify google.golang.org/grpc/codes.InvalidArgument in pkg:golang/google.golang.org/grpc@v1.82.0",
"kind": "HOW",
"packages": [
"pkg:golang/google.golang.org/grpc@v1.82.0"
],
"symbols": [
"google.golang.org/grpc/codes.InvalidArgument"
]
}
package contract_test
import (
"encoding/json"
"errors"
"testing"
invalidargument "example.com/invalidargument"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func TestInvalidArgumentValueAndString(t *testing.T) {
if got := invalidargument.InvalidArgumentCode(); got != codes.InvalidArgument {
t.Fatalf("expected InvalidArgumentCode() == codes.InvalidArgument, got %v", got)
}
if codes.InvalidArgument != 3 {
t.Fatalf("expected codes.InvalidArgument == 3, got %d", codes.InvalidArgument)
}
if got := codes.InvalidArgument.String(); got != "InvalidArgument" {
t.Fatalf("expected codes.InvalidArgument.String() == %q, got %q", "InvalidArgument", got)
}
}
func TestInvalidArgumentJSONUnmarshal(t *testing.T) {
var c codes.Code
// Unmarshal string representation "INVALID_ARGUMENT"
if err := json.Unmarshal([]byte(`"INVALID_ARGUMENT"`), &c); err != nil {
t.Fatalf("json.Unmarshal INVALID_ARGUMENT failed: %v", err)
}
if c != codes.InvalidArgument {
t.Fatalf("expected codes.InvalidArgument, got %v", c)
}
// Unmarshal numeric representation 3
var cNum codes.Code
if err := json.Unmarshal([]byte(`3`), &cNum); err != nil {
t.Fatalf("json.Unmarshal 3 failed: %v", err)
}
if cNum != codes.InvalidArgument {
t.Fatalf("expected codes.InvalidArgument, got %v", cNum)
}
}
func TestInvalidArgumentStatusAndHelper(t *testing.T) {
msg := "invalid parameter provided"
err := invalidargument.NewInvalidArgumentError(msg)
if err == nil {
t.Fatalf("expected non-nil error")
}
if !invalidargument.IsInvalidArgument(err) {
t.Fatalf("expected IsInvalidArgument(err) to be true")
}
st, ok := status.FromError(err)
if !ok {
t.Fatalf("expected status.FromError to return ok == true")
}
if st.Code() != codes.InvalidArgument {
t.Fatalf("expected status code %v, got %v", codes.InvalidArgument, st.Code())
}
if st.Message() != msg {
t.Fatalf("expected message %q, got %q", msg, st.Message())
}
// Verify other errors are not considered InvalidArgument
otherErr := status.Error(codes.NotFound, "not found")
if invalidargument.IsInvalidArgument(otherErr) {
t.Fatalf("expected IsInvalidArgument(otherErr) to be false")
}
genericErr := errors.New("generic error")
if invalidargument.IsInvalidArgument(genericErr) {
t.Fatalf("expected IsInvalidArgument(genericErr) to be false")
}
}
Seeder d'origine
anonyme