Skip to content

fix(metadata:rename): resolve -o flag collision hiding default org (#443)#449

Merged
msrivastav13 merged 2 commits into
masterfrom
fix/issue-443-rename-org-flag-collision
Jun 19, 2026
Merged

fix(metadata:rename): resolve -o flag collision hiding default org (#443)#449
msrivastav13 merged 2 commits into
masterfrom
fix/issue-443-rename-org-flag-collision

Conversation

@msrivastav13

Copy link
Copy Markdown
Owner

Summary

Fixes #443sf metadata rename appeared to stop detecting the default org after 1.0.0.

Root cause

This is a flag-character collision, not a default-org regression. In metadata/rename.ts:

  • --target-org (via requiredOrgFlagWithDeprecations) uses char -o
  • --oldfullname also declared char -o

So sf metadata rename -t Skill -o A -n B routed -o A into --target-org, and the CLI then looked for an org literally named A:

Error (NamedOrgNotFoundError): No authorization information found for A.

It worked in 0.3.2 because the org flag was -u (--targetusername), leaving -o free for the old name. The ESM modernization switched to the -o-based org flag, silently colliding.

Fix

  • Move --oldfullname to char -d so -o maps to --target-org (consistent with every other command in this plugin and the sf CLI convention).
  • With the collision gone, --target-org auto-detects the configured default org when omitted — restoring the pre-1.0.0 behavior the issue describes.
  • Updated the in-command examples and the README usage block (the README also had stale -u/--targetusername docs, now corrected).

New usage

sf metadata rename -t CustomObject -d MyObject__c -n RenamedObject__c
# -o / --target-org  -> org (optional; defaults to the default org)
# -d / --oldfullname -> old name
# -n / --newfullname -> new name

Verification

  • tsc -p . --noEmit — clean
  • npm test — 57 passing
  • metadata:rename --help now shows -d, --oldfullname and -o, --target-org ("Not required if the target-org configuration variable is already set")

Note

metadata:rename was the only command with this -o collision — all other commands already reserve -o for the org flag.

)

The modern requiredOrgFlagWithDeprecations claims -o for --target-org,
but --oldfullname also used char 'o'. So 'sf metadata rename -t X -o A -n B'
routed '-o A' to --target-org, producing 'No authorization information
found for A' and making it look like the default org was no longer
detected (it worked in 0.3.2 when the org flag was -u).

Move --oldfullname to char 'd' so -o maps to --target-org. The org flag
then auto-detects the configured default org when omitted, restoring the
pre-1.0.0 behavior. Updated in-command examples and the README usage.

Fixes #443
The plugin targets the modern sf CLI, but every command's examples= still
showed the deprecated sfdx executable. Swap '$ sfdx' -> '$ sf' across all
10 commands. Also fix the dxsource example that used the old -u flag (now
-o/--target-org).

Note: the runtime 'sfdx force:mdapi:*' shell calls in retrieve/* and
service/* are intentionally left for a separate migration to
'sf project retrieve/convert' (behavior change, needs org testing).
@msrivastav13
msrivastav13 merged commit d92a37d into master Jun 19, 2026
3 checks passed
@msrivastav13 msrivastav13 mentioned this pull request Jun 19, 2026
msrivastav13 added a commit that referenced this pull request Jun 19, 2026
Minor release bundling the changes merged since 1.1.0:
- fix(metadata:rename): resolve -o flag collision hiding default org (#443, #449)
- fix(security): patch all known dependency vulnerabilities (#447)
- chore(deps): bump @salesforce/core to ^8.31.1 (#448)
- docs: use 'sf' instead of 'sfdx' in command examples (#449)

Verified: npm ci clean, 0 vulnerabilities, 57 tests passing, prepack builds.
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.

Version 1.0.0 don't detect the default org

1 participant