1

I'm getting Error 20001 when I try to delete a function from a previous build.

Steps to reproduce error:

twilio serverless:init my-project
twilio serverless:deploy
rm functions/private-message.js /functions/sms/reply.protected.js /assets/style.css /assets/message.private.js /assets/index.html
twilio serverless:deploy
twilio api:serverless:v1:services:functions:list --service-sid ZSXXXXXXXXXXXXXXXX
twilio api:serverless:v1:services:functions:remove \
--service-sid ZSXXXXXXXXXXXXXXXX \
--sid ZHXXXXXXXXXXXXXXXX

After last command I'm getting this error:

» Error code 20001 from Twilio: Cannot delete function. One or more of its versions is referenced in a Build.. See https://www.twilio.com/docs/errors/20001 for more info

If I enter "Twilio Console > Functions and Assets > Services", then:

  • Clicking on the Service's Unique Name, I see removed functions in grey (not green). I'm expecting not to see these functions listed.
  • Clicking on Service Details (screen with title "Live Build Details"), removed functions are not listed. So there not should be an active build referencing those functions.

How should I proceed to completely delete these functions from the service?

1 Answers1

1

You can use the following command to remove a serverless function service:

twilio api:serverless:v1:services:remove --sid ZS…

You already mentioned it in your question, but I wanted to emphasize this for others who might come across it here. By default, function services created via a shell can only be removed from the shell. And function services created via the console can only be deleted via the console.

IObert
  • 2,118
  • 1
  • 10
  • 17
  • 1
    I don't want to remove the entire service. I only need to remove one function and I'm getting Error 20001 – Neuquino Dec 30 '22 at 01:04