fix: clarify actor not found error when ID is explicitly provided - #1337
fix: clarify actor not found error when ID is explicitly provided#1337kuntal1461 wants to merge 3 commits into
Conversation
a0081de to
cc3bc54
Compare
|
Hi @l2ysho, @DaveHanns, @patrikbraborec 👋 Just wanted to kindly check if you'd have a chance to review this PR when possible. I'm happy to make any changes or address any feedback. Thank you for your time! |
|
|
||
| export function formatActorContextError(reason: string, providedActorNameOrId?: string) { | ||
| if (providedActorNameOrId) { | ||
| return `${reason}. Check that the Actor ID or name is correct and that your API token has permission to access it.`; |
There was a problem hiding this comment.
@patrikbraborec Are you ok with this message or you would like also mention organization as you do in a issue description?
|
|
||
| import { getLocalConfig, getLocalUserInfo } from '../utils.js'; | ||
|
|
||
| export function formatActorContextError(reason: string, providedActorNameOrId?: string) { |
There was a problem hiding this comment.
No need to create helper function just for 2 occurrences (especially when we need to decide which to show inside). We are completely fine to have these 2 messages inline as original.
|
@patrikbraborec btw similar problem also in |
Remove formatActorContextError helper and inline the conditional message directly at each call site in actors info, builds create, builds ls, and runs ls. Drop the unit tests for the removed helper.
cc3bc54 to
aa99fbb
Compare
|
Thanks for the review @l2ysho! Removed the Happy to adjust the error message wording once @patrikbraborec shares their thoughts on whether to mention the organization. |
|
Thanks @kuntal1461. @szaganek - please can you review the text? Thanks! |
szaganek
left a comment
There was a problem hiding this comment.
I'd suggest rephrasing the first message and getting rid of please.
| if (!ctx.valid) { | ||
| error({ | ||
| message: `${ctx.reason}. Please specify the Actor ID.`, | ||
| message: `${ctx.reason}. Check that the Actor ID or name is correct and that your API token has permission to access it.`, |
There was a problem hiding this comment.
| message: `${ctx.reason}. Check that the Actor ID or name is correct and that your API token has permission to access it.`, | |
| message: `${ctx.reason}. Check that the ID or name is correct and that your API token has access to this Actor.`, |
To avoid dangling it.
| error({ | ||
| message: `${ctx.reason}. Please run this command in an Actor directory, or specify the Actor ID.`, | ||
| message: actorId | ||
| ? `${ctx.reason}. Check that the Actor ID or name is correct and that your API token has permission to access it.` |
There was a problem hiding this comment.
| ? `${ctx.reason}. Check that the Actor ID or name is correct and that your API token has permission to access it.` | |
| ? `${ctx.reason}. Check that the ID or name is correct and that your API token has access to this Actor.` |
| message: `${ctx.reason}. Please run this command in an Actor directory, or specify the Actor ID.`, | ||
| message: actorId | ||
| ? `${ctx.reason}. Check that the Actor ID or name is correct and that your API token has permission to access it.` | ||
| : `${ctx.reason}. Please run this command in an Actor directory, or specify the Actor ID.`, |
There was a problem hiding this comment.
| : `${ctx.reason}. Please run this command in an Actor directory, or specify the Actor ID.`, | |
| : `${ctx.reason}. Run this command in an Actor directory, or specify the Actor ID.`, |
| error({ | ||
| message: `${ctx.reason}. Please run this command in an Actor directory, or specify the Actor ID.`, | ||
| message: actorId | ||
| ? `${ctx.reason}. Check that the Actor ID or name is correct and that your API token has permission to access it.` |
There was a problem hiding this comment.
| ? `${ctx.reason}. Check that the Actor ID or name is correct and that your API token has permission to access it.` | |
| ? `${ctx.reason}. Check that the ID or name is correct and that your API token has access to this Actor.` |
| message: `${ctx.reason}. Please run this command in an Actor directory, or specify the Actor ID.`, | ||
| message: actorId | ||
| ? `${ctx.reason}. Check that the Actor ID or name is correct and that your API token has permission to access it.` | ||
| : `${ctx.reason}. Please run this command in an Actor directory, or specify the Actor ID.`, |
There was a problem hiding this comment.
| : `${ctx.reason}. Please run this command in an Actor directory, or specify the Actor ID.`, | |
| : `${ctx.reason}. Run this command in an Actor directory, or specify the Actor ID.`, |
| error({ | ||
| message: `${ctx.reason}. Please run this command in an Actor directory, or specify the Actor ID.`, | ||
| message: actorId | ||
| ? `${ctx.reason}. Check that the Actor ID or name is correct and that your API token has permission to access it.` |
There was a problem hiding this comment.
| ? `${ctx.reason}. Check that the Actor ID or name is correct and that your API token has permission to access it.` | |
| ? `${ctx.reason}. Check that the ID or name is correct and that your API token has access to this Actor.` |
| message: `${ctx.reason}. Please run this command in an Actor directory, or specify the Actor ID.`, | ||
| message: actorId | ||
| ? `${ctx.reason}. Check that the Actor ID or name is correct and that your API token has permission to access it.` | ||
| : `${ctx.reason}. Please run this command in an Actor directory, or specify the Actor ID.`, |
There was a problem hiding this comment.
| : `${ctx.reason}. Please run this command in an Actor directory, or specify the Actor ID.`, | |
| : `${ctx.reason}. Run this command in an Actor directory, or specify the Actor ID.`, |
- Replace "Actor ID or name" with "ID or name" (redundant in context) - Replace "permission to access it" with "has access to this Actor" (avoids dangling "it") - Remove "Please" from the no-actorId fallback message Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thanks @szaganek for the review! Applied all suggestions:
All four commands ( |
Closes #1147
What changed
formatActorContextError(reason, actorId)helper inresolve-actor-context.tsactorIdis provided, error omits "run in an Actor directory / specify the Actor ID" suggestions and instead hints at token/permission accessactorIdis provided, original fallback message is preservedactors info,builds create,builds ls,runs lsWhy
The old message suggested the user specify an Actor ID even when they already had — misleading when the real cause is a token with no access to an org Actor.
Test
formatActorContextErrorintest/unit/lib/commands/resolve-actor-context.test.tscovering both the ID-provided and no-ID pathsInstall size
No new dependencies added.