サンプル
google.golang.org/genproto/googleapis/rpc v0.0.0-20250728155136-f173205681a0: code.Code_INVALID_ARGUMENT
検証済みサンプル — golang google.golang.org/genproto/googleapis/rpc v0.0.0-20250728155136-f173205681a0: code.Code_INVALID_ARGUMENT. go 1.26 · linux debian/x64 …
sha256:7493866d8159b77297bc5826d444b2a614211b68db1204bb04b65a3728ac8159
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
linux 24 · ubuntu · glibc 2.39 x64 go
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| 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-09-15 |
ケース
HOW- ゴール
- verify google.golang.org/genproto/googleapis/rpc/code.Code_INVALID_ARGUMENT in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20250728155136-f173205681a0
- シンボル
-
- google.golang.org/genproto/googleapis/rpc/code.Code_INVALID_ARGUMENT
- 作成日
- 2026-09-15T21:40:28Z
コントラクト
- code.Code_INVALID_ARGUMENT represents client-specified invalid argument with enum value 3
- code.Code_INVALID_ARGUMENT enum converts to string representation INVALID_ARGUMENT and maps in Code_name and Code_value
- status.Status represents an RPC error status with code.Code_INVALID_ARGUMENT and unmarshals successfully
- status.Status with code.Code_INVALID_ARGUMENT encapsulates BadRequest error details describing invalid field arguments
ファイル
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
ソース
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/genproto/googleapis/rpc/code.Code_INVALID_ARGUMENT in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20250728155136-f173205681a0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20250728155136-f173205681a0
Demonstrate these symbols/APIs:
- google.golang.org/genproto/googleapis/rpc/code.Code_INVALID_ARGUMENT
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:4004ab04cc10d23ec59f81a29e9f04ccd45e6834ffb6c0b0cb04e013c2ec9070","contract":["code.Code_INVALID_ARGUMENT represents client-specified invalid argument with enum value 3","code.Code_INVALID_ARGUMENT enum converts to string representation INVALID_ARGUMENT and maps in Code_name and Code_value","status.Status represents an RPC error status with code.Code_INVALID_ARGUMENT and unmarshals successfully","status.Status with code.Code_INVALID_ARGUMENT encapsulates BadRequest error details describing invalid field arguments"],"goal":"verify google.golang.org/genproto/googleapis/rpc/code.Code_INVALID_ARGUMENT in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20250728155136-f173205681a0","kind":"HOW","packages":["pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20250728155136-f173205681a0"],"schemaVersion":1,"symbols":["google.golang.org/genproto/googleapis/rpc/code.Code_INVALID_ARGUMENT"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20250728155136-f173205681a0"],"schemaVersion":1,"subject":"pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20250728155136-f173205681a0","symbols":["google.golang.org/genproto/googleapis/rpc/code.Code_INVALID_ARGUMENT"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.25.0
require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20250728155136-f173205681a0
google.golang.org/protobuf v1.36.6
)
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250728155136-f173205681a0 h1:MAKi5q709QWfnkkpNQ0M12hYJ1+e8qYVDyowc4U1XZM=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250728155136-f173205681a0/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
package main
import (
"fmt"
"log"
"google.golang.org/genproto/googleapis/rpc/code"
"google.golang.org/genproto/googleapis/rpc/errdetails"
"google.golang.org/genproto/googleapis/rpc/status"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
)
func main() {
badRequest := &errdetails.BadRequest{
FieldViolations: []*errdetails.BadRequest_FieldViolation{
{
Field: "user_id",
Description: "user ID cannot be empty",
},
},
}
anyDetail, err := anypb.New(badRequest)
if err != nil {
log.Fatalf("failed to pack error detail: %v", err)
}
st := &status.Status{
Code: int32(code.Code_INVALID_ARGUMENT),
Message: "invalid argument provided in request",
Details: []*anypb.Any{anyDetail},
}
data, err := proto.Marshal(st)
if err != nil {
log.Fatalf("failed to marshal status: %v", err)
}
var decoded status.Status
if err := proto.Unmarshal(data, &decoded); err != nil {
log.Fatalf("failed to unmarshal status: %v", err)
}
fmt.Printf("Status Code: %d (%s)\n", decoded.GetCode(), code.Code_name[decoded.GetCode()])
fmt.Printf("Status Message: %s\n", decoded.GetMessage())
}
{
"schemaVersion": 1,
"goal": "verify google.golang.org/genproto/googleapis/rpc/code.Code_INVALID_ARGUMENT in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20250728155136-f173205681a0",
"kind": "HOW",
"packages": [
"pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20250728155136-f173205681a0"
],
"symbols": [
"google.golang.org/genproto/googleapis/rpc/code.Code_INVALID_ARGUMENT"
]
}
package main
import (
"fmt"
"os"
"google.golang.org/genproto/googleapis/rpc/code"
"google.golang.org/genproto/googleapis/rpc/errdetails"
"google.golang.org/genproto/googleapis/rpc/status"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
)
func assert(condition bool, message string) {
if !condition {
fmt.Fprintf(os.Stderr, "Assertion failed: %s\n", message)
os.Exit(1)
}
}
func main() {
// 1. code.Code_INVALID_ARGUMENT represents client-specified invalid argument with enum value 3
assert(code.Code_INVALID_ARGUMENT == 3, "code.Code_INVALID_ARGUMENT must have value 3")
assert(int32(code.Code_INVALID_ARGUMENT) == 3, "int32(code.Code_INVALID_ARGUMENT) must be 3")
// 2. code.Code_INVALID_ARGUMENT enum converts to string representation INVALID_ARGUMENT and maps in Code_name and Code_value
assert(code.Code_INVALID_ARGUMENT.String() == "INVALID_ARGUMENT", "code.Code_INVALID_ARGUMENT.String() must be INVALID_ARGUMENT")
assert(code.Code_name[int32(code.Code_INVALID_ARGUMENT)] == "INVALID_ARGUMENT", "code.Code_name[3] must be INVALID_ARGUMENT")
assert(code.Code_value["INVALID_ARGUMENT"] == int32(code.Code_INVALID_ARGUMENT), "code.Code_value[INVALID_ARGUMENT] must match Code_INVALID_ARGUMENT")
// 3. status.Status represents an RPC error status with code.Code_INVALID_ARGUMENT and unmarshals successfully
st := &status.Status{
Code: int32(code.Code_INVALID_ARGUMENT),
Message: "invalid argument: user ID cannot be empty",
}
assert(st.GetCode() == int32(code.Code_INVALID_ARGUMENT), "status code must match Code_INVALID_ARGUMENT")
assert(st.GetMessage() == "invalid argument: user ID cannot be empty", "status message must match")
data, err := proto.Marshal(st)
assert(err == nil, "proto.Marshal(st) must succeed")
assert(len(data) > 0, "marshaled payload must not be empty")
var decoded status.Status
err = proto.Unmarshal(data, &decoded)
assert(err == nil, "proto.Unmarshal(data) must succeed")
assert(decoded.GetCode() == int32(code.Code_INVALID_ARGUMENT), "decoded status code must match Code_INVALID_ARGUMENT")
assert(decoded.GetMessage() == "invalid argument: user ID cannot be empty", "decoded message must match")
// 4. status.Status with code.Code_INVALID_ARGUMENT encapsulates BadRequest error details describing invalid field arguments
badRequest := &errdetails.BadRequest{
FieldViolations: []*errdetails.BadRequest_FieldViolation{
{
Field: "user_id",
Description: "user ID cannot be empty",
},
},
}
anyDetail, err := anypb.New(badRequest)
assert(err == nil, "anypb.New(badRequest) must succeed")
st.Details = append(st.Details, anyDetail)
assert(len(st.GetDetails()) == 1, "details count must be 1")
unpackedBadReq := &errdetails.BadRequest{}
err = anypb.UnmarshalTo(st.GetDetails()[0], unpackedBadReq, proto.UnmarshalOptions{})
assert(err == nil, "anypb.UnmarshalTo must succeed")
assert(len(unpackedBadReq.GetFieldViolations()) == 1, "field violations count must be 1")
assert(unpackedBadReq.GetFieldViolations()[0].GetField() == "user_id", "violation field must match")
assert(unpackedBadReq.GetFieldViolations()[0].GetDescription() == "user ID cannot be empty", "violation description must match")
fmt.Println("All contract assertions for Code_INVALID_ARGUMENT passed successfully.")
}
オリジンシーダー
匿名