Skip to content

Upd/fix big ctx#3

Merged
SUNsung merged 3 commits into
mainfrom
upd/fix-big-ctx
Jul 2, 2026
Merged

Upd/fix big ctx#3
SUNsung merged 3 commits into
mainfrom
upd/fix-big-ctx

Conversation

@SUNsung

@SUNsung SUNsung commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Streaming hardening, Bitbucket cursor fix, and _run migration to gometagen

Streaming / pagination

  • New StreamPages helper (stream.go): drives offset-based pagination for all providers, adaptively halving the page size when a response exceeds the GetJSON 8 MiB body cap (ErrResponseTooLarge). Offset-based remap guarantees no duplicated or skipped items after a shrink.
  • New Send helper: every channel send in every stream now goes through select { send / ctx.Done() }. Previously a canceled context could not unblock a stream whose consumer stopped reading — the goroutine leaked forever.
  • StreamPages input validation: perPage <= 0 or nil fetch/emit returns an error instead of panicking (division by zero). Nil context is normalized to context.Background() everywhere.

Bug fixes

  • Bitbucket TagsStream broke on page 2+: it appended the absolute next cursor URL to the API root, producing .../repositories/owner/repo/https://api.bitbucket.org/.... Now uses getJSONAny (moved to bitbucket/func.go) like the release code already did. Only visible on repos with >50 tags.
  • Nil-pointer dereference on malformed asset URLs: url.Parse errors were ignored and the result dereferenced in github.buildReleaseObj and bitbucket.listDownloads. Broken assets are now skipped.
  • GetJSON reports an explicit ErrResponseTooLarge sentinel instead of a misleading truncated-JSON decode error.

_run migration (bash scripts → gometagen)

  • _run/values/{name,ver}.txt + ~400 lines of bash (sys.sh, git.sh, go_creator_const.sh) replaced by _run/values.yml and gometagen (version bump, branch name, hook install, meta generation).
  • Fixes previously broken firststart.sh/push-hook.sh (both called a non-existent go_tidy_all.sh); all scripts now run with set -Eeuo pipefail.
  • gen.go generates target/meta_gen.go via gometagen generate (content hash instead of git hash).
  • CI updated in the same change: generate-build-env and the release version-bump step now read/write values.yml via gometagen.

Tests

  • New hermetic test suite (tests/pagination_test.go, httptest + client swap, no real network): adaptive page shrink with exact request-sequence assertions, body-cap edge cases, cancel-unblocks-send, Bitbucket next-cursor following, parameter validation.
  • Network-dependent tests (provider func_test.go, TestGlobal) are skipped under -short; the commit hook runs go test -short ./... so commits don't fail on provider rate limits.

README

  • Authentication section: examples of attaching API tokens via a custom RoundTripper on lightweigit.HttpClient (GitHub Bearer, GitLab PRIVATE-TOKEN, Bitbucket), host-scoped for multi-provider use.
  • New "Development setup" section: generated target/ package, _run/firststart.sh bootstrap (Linux/macOS), manual steps for Windows.

⚠️ Breaking change

target package constants renamed: GlobalName/GlobalVersion/GlobalHash/GlobalVersionMajor/GlobalVersionMinor/GlobalVersionPatchName/Version/Hash/VersionMajor/VersionMinor/VersionPatch (GlobalDateUpdateDateUpdate). Affects consumers importing target from release tags. Covered by the upcoming minor bump (v0.x).

SUNsung added 2 commits July 2, 2026 18:48
feat(pagination): add cursor-based streaming across providers

- Add getJSONAny to Bitbucket to follow absolute `next` cursor URLs
  while keeping relative paths resolved against the repo API root
- Rework TagsStream to honor context cancellation and use a safer
  default page size (50) that stays within the 8 MiB GetJSON cap
- Skip release assets with unparseable download URLs instead of
  dereferencing a nil URL on GitHub
- Add stream.go and pagination tests
build(deps): replace shell version scripts with gometagen

- Migrate build tooling from _run/scripts/*.sh to the
  gometagen CLI for manifest and version management
- Read package name and version from _run/values.yml via
  gometagen manifest/version commands in CI actions
- Update release workflow to bump minor version through
  gometagen and stage values.yml
- Rewrite commit-hook.sh and firststart.sh to use gometagen
  for version, branch, and git hook installation
- Add _run/values.yml as the single source of truth,
  removing values/name.txt and values/ver.txt
- Delete obsolete git.sh, go_creator_const.sh, and sys.sh
- Harden hook scripts with set -Eeuo pipefail and safe
  temp-file rewrites
@SUNsung SUNsung self-assigned this Jul 2, 2026
@SUNsung SUNsung merged commit 75ab8cb into main Jul 2, 2026
4 checks passed
@SUNsung SUNsung deleted the upd/fix-big-ctx branch July 2, 2026 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant