Skip to content

fix(file): Replace Read with ReadText/ReadBytes, fix Link param (#222) - #223

Merged
David-Noble-at-work merged 1 commit into
developfrom
fix/file-read
Mar 15, 2026
Merged

David-Noble-at-work merged 1 commit into
developfrom
fix/file-read

Conversation

@David-Noble-at-work

Copy link
Copy Markdown
Contributor

Summary

Closes #222 (partial — addresses the "Broken: Read returns Resource metadata, not file content" section).

Read → ReadText + ReadBytes

  • file.Provider.Read removed. Replaced with ReadText (Resource) → (string, error) and ReadBytes (Resource) → ([]byte, error).
  • Both delegate to a shared read helper that uses Resource.WriteTo to stream content into a *bytes.Buffer.
  • plan.source() now wires to file.read_text (was file.read).
  • Starlark slot name changed from path to resource to match the Go parameter name.

Link param fix

  • The Link method's second Go parameter was renamed path → target in a prior commit, but the generated params.gen.go was stale. Regeneration exposed the mismatch, causing all file.link Starlark calls to fail with "unexpected keyword argument path".
  • Fixed all Starlark test scripts and Go test helpers to use target=.

Doc compliance

  • Added Parameters: / Returns: sections to all 9 Compensate* methods that were missing them.
  • Improved Link doc comment for clarity.
  • Renamed readlink → readLink (camelCase consistency).

Housekeeping

Test plan

  • make vet passes
  • make test passes — all packages green
  • CI confirms (make check requires golangci-lint)

…222)

file.Provider.Read returned a Resource struct (metadata) but never read
file content. Replace with ReadText (returns string) and ReadBytes
(returns []byte), both backed by Resource.WriteTo.

Also fixes a latent bug: the Link method's second parameter was renamed
from "path" to "target" in Go but the generated params still used "path",
causing Starlark callers to fail after regeneration.

Additional changes:
- Add Parameters/Returns doc comments to all Compensate* methods
- Rename readlink → readLink for camelCase consistency
- Update plan.source() to use file.read_text action
- Commit completed structured-document-io plan (issue #218)
- Update architecture docs for new Read path and migration tables
@David-Noble-at-work
David-Noble-at-work merged commit 7081f5d into develop Mar 15, 2026
2 checks passed
@David-Noble-at-work
David-Noble-at-work deleted the fix/file-read branch March 15, 2026 21:26
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.

File provider: add ReadString method and List support for nf-ops migration

1 participant