Repository navigation
feat(dependencies): add workflow, credential and data-table dependency lookups - #43
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: sharedDependency/DependencyPagetypes (the three response schemas are identical:dependencyListPublicDto), relation-type constants,ValidateDependencyOptions(limit 0–250). Client methodsWorkflowDependencies,CredentialDependenciesandDataTableDependencieslive in their resource files and path-escape the ID.internal/cli/dependency.go: one shared command builder and runner.--limit(1–250, checked locally),--cursor,--all(usescollectPage, 10,000 cap, adds acollectionobject and a stderr warning),--output text|json.data,nextCursor,inaccessibleCount).RELATION / TYPE / ID / NAME / PROJECTtable where RELATION isusesorused by, then the next cursor.workflow:read,credential:read,dataTable:read) throughforbiddenScopeErrorand points ton8n discover --resource …. A 404 points to the matchinglistcommand and todiscover, because an instance that predates these endpoints also answers 404.data-table dependenciesusesdataTableClient, so the group's API-key-only rule applies before any request.dependenciesaction.scope_test.goandhelp_test.gohave the new entries.implementedwith their command paths; availability is unchanged.deliveredThroughis now 34, since phase 34 had only these ops.make docs.test/integration/dependency_test.gois read-only. It looks up the first existing workflow, credential and data table, and runs one full-CLIworkflow 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 checkpasses 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) andinternal/cli/dependency_test.go(text and JSON for all 3 commands,--allacross pages keepinginaccessibleCount, 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 checkpasses locallymake docsrun 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
openapi.upstream.yml(2.46.4) present.TestAvailabilityMatchesSpecsskipped because no instanceopenapi.ymlwas available. Availability values were not touched.inaccessibleCountcovers the whole list: upstream builds the full list and then paginates the array in memory (dependency.mapper.js), so every page repeats it.--allkeeps the largest value it sees.🤖 Generated with Claude Code