Skip to content

feat(dependencies): add workflow, credential and data-table dependency lookups - #43

Merged
SomeoneWithOptions merged 1 commit into
mainfrom
feat/dependencies
Nov 4, 2026
Merged

SomeoneWithOptions merged 1 commit into
mainfrom
feat/dependencies

Conversation

@SomeoneWithOptions

Copy link
Copy Markdown
Owner

What / why

Implements the three read-only dependency lookups from the n8n 2.46.4 Public API (phase 34 in the coverage manifest):

  • GET /workflows/{workflowId}/dependencies → n8n workflow dependencies <workflow-id>
  • GET /credentials/{credentialId}/dependencies → n8n credential dependencies <credential-id>
  • GET /data-tables/{dataTableId}/dependencies → n8n data-table dependencies <table-id>

Use them to see what breaks before you archive, delete, transfer or rotate a resource.

Changes

  • internal/n8n/dependency.go: shared Dependency / DependencyPage types (the three response schemas are identical: dependencyListPublicDto), relation-type constants, ValidateDependencyOptions (limit 0–250). Client methods WorkflowDependencies, CredentialDependencies and DataTableDependencies live in their resource files and path-escape the ID.
  • internal/cli/dependency.go: one shared command builder and runner.
    • Flags: --limit (1–250, checked locally), --cursor, --all (uses collectPage, 10,000 cap, adds a collection object and a stderr warning), --output text|json.
    • JSON output is the API page (data, nextCursor, inaccessibleCount).
    • Text output prints a summary (subject, count, inaccessible count, instance), then a RELATION / TYPE / ID / NAME / PROJECT table where RELATION is uses or used by, then the next cursor.
    • stderr carries the empty-result hint and a note when dependencies are hidden.
  • Errors: a 403 names the required scope (workflow:read, credential:read, dataTable:read) through forbiddenScopeError and points to n8n discover --resource …. A 404 points to the matching list command and to discover, because an instance that predates these endpoints also answers 404.
  • data-table dependencies uses dataTableClient, so the group's API-key-only rule applies before any request.
  • Scope mappers handle the new dependencies action. scope_test.go and help_test.go have the new entries.
  • Manifest: the 3 ops are now implemented with their command paths; availability is unchanged. deliveredThrough is now 34, since phase 34 had only these ops.
  • Docs regenerated with make docs.
  • test/integration/dependency_test.go is read-only. It looks up the first existing workflow, credential and data table, and runs one full-CLI workflow dependencies --all --output json. It skips when the env is unset or when the instance answers 404 for an ID it just listed.

Verification

  • make check passes locally: fmt, vet, staticcheck, test, test-race, cross builds, tidy, govulncheck.

  • New tests: internal/n8n/dependency_test.go (paths, escaping, query, decoding, null cursor, validation before any request, status kept) and internal/cli/dependency_test.go (text and JSON for all 3 commands, --all across pages keeping inaccessibleCount, 401/403/404 messages, validation before any request, API-key requirement).

  • Integration tests skip without N8N_INTEGRATION_URL / N8N_INTEGRATION_API_KEY. They were not run against a live instance.

  • make check passes locally

  • make docs run if CLI help changed (docs/README.md updated)

  • No secrets/keys/tokens in diff or logs

  • No v* tag or release commit in this PR (maintainer releases separately)

Notes for reviewer

  • Coverage ran with openapi.upstream.yml (2.46.4) present. TestAvailabilityMatchesSpecs skipped because no instance openapi.yml was available. Availability values were not touched.
  • inaccessibleCount covers the whole list: upstream builds the full list and then paginates the array in memory (dependency.mapper.js), so every page repeats it. --all keeps the largest value it sees.
  • Data-table IDs are checked only for blank or whitespace input, the same as the other data-table commands. The spec's 16-character nanoid pattern is not enforced locally.

🤖 Generated with Claude Code

…y lookups

- n8n workflow|credential|data-table dependencies <id>: GET
  /{workflows,credentials,data-tables}/{id}/dependencies (n8n 2.46.4),
  one shared DependencyPage client type with path-escaped IDs.
- --limit (1-250, validated locally), --cursor, --all (10,000 cap with
  collection report), --output text|json. JSON keeps the API page shape
  incl. inaccessibleCount; text adds a uses / used-by relation column and
  notes hidden dependencies on stderr.
- 403 names the required scope (workflow:read, credential:read,
  dataTable:read); 404 points at the matching list command and at
  'n8n discover' for instances that predate the endpoints.
- data-table dependencies keeps the group's API-key-only rule.
- Manifest: phase 34 implemented; deliveredThrough raised to 34.
- Client + CLI tests, read-only opt-in integration test, docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@SomeoneWithOptions
SomeoneWithOptions merged commit 3c65d0f into main Nov 4, 2026
5 checks passed
@SomeoneWithOptions
SomeoneWithOptions deleted the feat/dependencies branch November 4, 2026 03: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