샘플
github.com/klauspost/compress v1.19.1: zlib.ErrDictionary
검증된 샘플 — golang github.com/klauspost/compress v1.19.1: zlib.ErrDictionary. go 1.26 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다.
sha256:f0a08ad38b37766137bc4b0469f37da7d06a11b23f25d4f3254f9928329a07d3
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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-10-11 |
케이스
HOW- 목표
- verify github.com/klauspost/compress/zlib.ErrDictionary in pkg:golang/github.com/klauspost/compress@v1.19.1
- 심벌
-
- github.com/klauspost/compress/zlib.ErrDictionary
- 생성일
- 2026-10-11T09:17:34Z
컨트랙트
- ErrDictionary is the sentinel error variable exported by zlib with message "zlib: invalid dictionary"
- NewReader returns ErrDictionary when decompressing a zlib stream that requires a preset dictionary
- NewReaderDict returns ErrDictionary when decompressing a stream with an incorrect preset dictionary
- Resetter.Reset returns ErrDictionary when resetting an existing reader with an incorrect dictionary for dictionary-compressed data
- NewReaderDict succeeds and does not return ErrDictionary when the correct preset dictionary is provided
파일
- 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 github.com/klauspost/compress/zlib.ErrDictionary in pkg:golang/github.com/klauspost/compress@v1.19.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/klauspost/compress@v1.19.1
Demonstrate these symbols/APIs:
- github.com/klauspost/compress/zlib.ErrDictionary
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:de85638620af166e2a901a7eecf131842ec3403b8e670db73909dd8f1b8fb326","contract":["ErrDictionary is the sentinel error variable exported by zlib with message \"zlib: invalid dictionary\"","NewReader returns ErrDictionary when decompressing a zlib stream that requires a preset dictionary","NewReaderDict returns ErrDictionary when decompressing a stream with an incorrect preset dictionary","Resetter.Reset returns ErrDictionary when resetting an existing reader with an incorrect dictionary for dictionary-compressed data","NewReaderDict succeeds and does not return ErrDictionary when the correct preset dictionary is provided"],"goal":"verify github.com/klauspost/compress/zlib.ErrDictionary in pkg:golang/github.com/klauspost/compress@v1.19.1","kind":"HOW","packages":["pkg:golang/github.com/klauspost/compress@v1.19.1"],"schemaVersion":1,"symbols":["github.com/klauspost/compress/zlib.ErrDictionary"]},"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/github.com/klauspost/compress@v1.19.1"],"schemaVersion":1,"subject":"pkg:golang/github.com/klauspost/compress@v1.19.1","symbols":["github.com/klauspost/compress/zlib.ErrDictionary"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require github.com/klauspost/compress v1.19.1
github.com/klauspost/compress v1.19.1 h1:VsB4HPswih7mmZ8WleSFQ75c/Ui1M4trX5oAsJnhSlk=
github.com/klauspost/compress v1.19.1/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
package main
import (
"bytes"
"errors"
"fmt"
"io"
"os"
"github.com/klauspost/compress/zlib"
)
func main() {
dict := []byte("example-zlib-dictionary")
payload := []byte("Demonstrating ErrDictionary error handling with klauspost/compress")
var buf bytes.Buffer
writer, err := zlib.NewWriterLevelDict(&buf, zlib.DefaultCompression, dict)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to create writer: %v\n", err)
os.Exit(1)
}
if _, err := writer.Write(payload); err != nil {
fmt.Fprintf(os.Stderr, "failed to write: %v\n", err)
os.Exit(1)
}
if err := writer.Close(); err != nil {
fmt.Fprintf(os.Stderr, "failed to close writer: %v\n", err)
os.Exit(1)
}
// Attempt to read without providing the required dictionary
compressedData := buf.Bytes()
_, err = zlib.NewReader(bytes.NewReader(compressedData))
if errors.Is(err, zlib.ErrDictionary) {
fmt.Printf("Successfully caught expected error: %v\n", err)
} else {
fmt.Fprintf(os.Stderr, "expected zlib.ErrDictionary, got: %v\n", err)
os.Exit(1)
}
// Now decompress successfully with the matching dictionary
reader, err := zlib.NewReaderDict(bytes.NewReader(compressedData), dict)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to open reader with dictionary: %v\n", err)
os.Exit(1)
}
defer reader.Close()
decompressed, err := io.ReadAll(reader)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to read decompressed data: %v\n", err)
os.Exit(1)
}
fmt.Printf("Decompressed %d bytes: %s\n", len(decompressed), string(decompressed))
}
{
"schemaVersion": 1,
"goal": "verify github.com/klauspost/compress/zlib.ErrDictionary in pkg:golang/github.com/klauspost/compress@v1.19.1",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/klauspost/compress@v1.19.1"
],
"symbols": [
"github.com/klauspost/compress/zlib.ErrDictionary"
]
}
package main
import (
"bytes"
"errors"
"fmt"
"io"
"os"
"github.com/klauspost/compress/zlib"
)
func main() {
if err := runContractTests(); err != nil {
fmt.Fprintf(os.Stderr, "Contract test failed: %v\n", err)
os.Exit(1)
}
fmt.Println("All contract tests passed successfully.")
}
func runContractTests() error {
// 1. ErrDictionary is the sentinel error variable exported by zlib with message "zlib: invalid dictionary"
{
if zlib.ErrDictionary == nil {
return fmt.Errorf("expected zlib.ErrDictionary to be non-nil")
}
if zlib.ErrDictionary.Error() != "zlib: invalid dictionary" {
return fmt.Errorf("expected error string 'zlib: invalid dictionary', got %q", zlib.ErrDictionary.Error())
}
}
// 2. NewReader returns ErrDictionary when decompressing a zlib stream that requires a preset dictionary
{
dict := []byte("contract-dictionary-alpha")
payload := []byte("Data compressed with preset dictionary that requires a dict on read.")
var buf bytes.Buffer
zw, err := zlib.NewWriterLevelDict(&buf, zlib.DefaultCompression, dict)
if err != nil {
return fmt.Errorf("assertion 2: NewWriterLevelDict failed: %w", err)
}
if _, err := zw.Write(payload); err != nil {
return fmt.Errorf("assertion 2: zw.Write failed: %w", err)
}
if err := zw.Close(); err != nil {
return fmt.Errorf("assertion 2: zw.Close failed: %w", err)
}
_, err = zlib.NewReader(&buf)
if !errors.Is(err, zlib.ErrDictionary) {
return fmt.Errorf("assertion 2: expected ErrDictionary from NewReader, got: %v", err)
}
}
// 3. NewReaderDict returns ErrDictionary when decompressing a stream with an incorrect preset dictionary
{
dictCorrect := []byte("correct-contract-dict-1")
dictWrong := []byte("wrong-contract-dict-2")
payload := []byte("Data compressed with dictCorrect to test dictionary mismatch detection.")
var buf bytes.Buffer
zw, err := zlib.NewWriterLevelDict(&buf, zlib.DefaultCompression, dictCorrect)
if err != nil {
return fmt.Errorf("assertion 3: NewWriterLevelDict failed: %w", err)
}
if _, err := zw.Write(payload); err != nil {
return fmt.Errorf("assertion 3: zw.Write failed: %w", err)
}
if err := zw.Close(); err != nil {
return fmt.Errorf("assertion 3: zw.Close failed: %w", err)
}
_, err = zlib.NewReaderDict(&buf, dictWrong)
if !errors.Is(err, zlib.ErrDictionary) {
return fmt.Errorf("assertion 3: expected ErrDictionary from NewReaderDict with wrong dict, got: %v", err)
}
}
// 4. Resetter.Reset returns ErrDictionary when resetting an existing reader with an incorrect dictionary for dictionary-compressed data
{
dictCorrect := []byte("valid-reset-dictionary")
dictWrong := []byte("invalid-reset-dictionary")
payload := []byte("Payload for verifying Resetter.Reset dictionary validation.")
var buf1 bytes.Buffer
zw1, err := zlib.NewWriterLevelDict(&buf1, zlib.DefaultCompression, dictCorrect)
if err != nil {
return fmt.Errorf("assertion 4: NewWriterLevelDict 1 failed: %w", err)
}
if _, err := zw1.Write(payload); err != nil {
return fmt.Errorf("assertion 4: zw1.Write failed: %w", err)
}
if err := zw1.Close(); err != nil {
return fmt.Errorf("assertion 4: zw1.Close failed: %w", err)
}
var buf2 bytes.Buffer
zw2, err := zlib.NewWriterLevelDict(&buf2, zlib.DefaultCompression, dictCorrect)
if err != nil {
return fmt.Errorf("assertion 4: NewWriterLevelDict 2 failed: %w", err)
}
if _, err := zw2.Write(payload); err != nil {
return fmt.Errorf("assertion 4: zw2.Write failed: %w", err)
}
if err := zw2.Close(); err != nil {
return fmt.Errorf("assertion 4: zw2.Close failed: %w", err)
}
zr, err := zlib.NewReaderDict(&buf1, dictCorrect)
if err != nil {
return fmt.Errorf("assertion 4: NewReaderDict initial failed: %w", err)
}
defer zr.Close()
resetter, ok := zr.(zlib.Resetter)
if !ok {
return fmt.Errorf("assertion 4: reader does not implement zlib.Resetter")
}
err = resetter.Reset(&buf2, dictWrong)
if !errors.Is(err, zlib.ErrDictionary) {
return fmt.Errorf("assertion 4: expected ErrDictionary from resetter.Reset with wrong dict, got: %v", err)
}
}
// 5. NewReaderDict succeeds and does not return ErrDictionary when the correct preset dictionary is provided
{
dict := []byte("correct-matching-dictionary-verification")
payload := []byte("Payload to prove matching dictionary succeeds without error.")
var buf bytes.Buffer
zw, err := zlib.NewWriterLevelDict(&buf, zlib.DefaultCompression, dict)
if err != nil {
return fmt.Errorf("assertion 5: NewWriterLevelDict failed: %w", err)
}
if _, err := zw.Write(payload); err != nil {
return fmt.Errorf("assertion 5: zw.Write failed: %w", err)
}
if err := zw.Close(); err != nil {
return fmt.Errorf("assertion 5: zw.Close failed: %w", err)
}
zr, err := zlib.NewReaderDict(&buf, dict)
if err != nil {
return fmt.Errorf("assertion 5: expected nil error from NewReaderDict, got: %v", err)
}
defer zr.Close()
decompressed, err := io.ReadAll(zr)
if err != nil {
return fmt.Errorf("assertion 5: io.ReadAll failed: %w", err)
}
if !bytes.Equal(decompressed, payload) {
return fmt.Errorf("assertion 5: decompressed bytes mismatch")
}
}
return nil
}
오리진 시더
익명