-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
elevenlabs analyzer #3850
base: main
Are you sure you want to change the base?
elevenlabs analyzer #3850
Conversation
If write permission API calls was not as expected than only we make read permission API calls | ||
This we only do for those API calls which does not add any resources to secretInfo | ||
*/ | ||
func getResources(client *http.Client, key string, secretInfo *SecretInfo) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Points to Consider for Implementation while getting resource:
-
Aggregate Errors:
Instead of failing on the first error, collect all errors encountered during the process and return them as a single aggregated error at the end. This ensures that users get a complete picture of what went wrong, rather than having to address issues one at a time. -
Graceful Error Handling in CLI:
For the CLI, log errors when checking a specific scope or fetching resource fails, but continue processing other tasks. Improving the user experience and allowing for partial success. -
Concurrent API Calls:
Use Go routines to call APIs concurrently. This will significantly improve performance by reducing the total time spent waiting for API responses.
Let me know your thoughts on these points.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My vote will be for concurrent API calls with error handling for each permission.
var secretInfo = &SecretInfo{} | ||
|
||
// validate the key and get user information | ||
if err := validateKey(client, key, secretInfo); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The func name validateKey
is confusing as this function is fetching the ElevenLabs User. Moreover, this function is also setting up User, Resource and Permissions in SecretInfo. I would recommend to break it multiple func.
if err := getHistory(client, key, secretInfo); err != nil { | ||
return err | ||
} | ||
|
||
if err := deleteHistory(client, key, secretInfo); err != nil { | ||
return err | ||
} | ||
|
||
// dubbings | ||
if err := deleteDubbing(client, key, secretInfo); err != nil { | ||
return err | ||
} | ||
|
||
// if dubbing write permission was not added | ||
if !permissionExist(secretInfo.Permissions, DubbingWrite) { | ||
if err := getDebugging(client, key, secretInfo); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
// voices | ||
if err := getVoices(client, key, secretInfo); err != nil { | ||
return err | ||
} | ||
|
||
if err := deleteVoice(client, key, secretInfo); err != nil { | ||
return err | ||
} | ||
|
||
// projects | ||
if err := getProjects(client, key, secretInfo); err != nil { | ||
return err | ||
} | ||
|
||
if err := deleteProject(client, key, secretInfo); err != nil { | ||
return err | ||
} | ||
|
||
// pronunciation dictionaries | ||
if err := getPronunciationDictionaries(client, key, secretInfo); err != nil { | ||
return err | ||
} | ||
|
||
if err := removePronunciationDictionariesRule(client, key, secretInfo); err != nil { | ||
return err | ||
} | ||
|
||
// models | ||
if err := getModels(client, key, secretInfo); err != nil { | ||
return err | ||
} | ||
|
||
// audio native | ||
if err := updateAudioNativeProject(client, key, secretInfo); err != nil { | ||
return err | ||
} | ||
|
||
// workspace | ||
if err := deleteInviteFromWorkspace(client, key, secretInfo); err != nil { | ||
return err | ||
} | ||
|
||
// text to speech | ||
if err := textToSpeech(client, key, secretInfo); err != nil { | ||
return err | ||
} | ||
|
||
// voice changer | ||
if err := speechToSpeech(client, key, secretInfo); err != nil { | ||
return err | ||
} | ||
|
||
// audio isolation | ||
if err := audioIsolation(client, key, secretInfo); err != nil { | ||
return err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are too many calls. is it possible to optimize them ? may be using go routines
} else if errorResp.Detail.Status == MissingPermissions { | ||
// key is missing user read permissions but is valid | ||
secretInfo.Valid = true | ||
color.Yellow("\n[!] API Key missing user read permissions") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AnalyzePermission
should only be gathering information from the service. As it is the common code calling from CLI and detectors.
If write permission API calls was not as expected than only we make read permission API calls | ||
This we only do for those API calls which does not add any resources to secretInfo | ||
*/ | ||
func getResources(client *http.Client, key string, secretInfo *SecretInfo) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My vote will be for concurrent API calls with error handling for each permission.
3ba85a9
to
4975781
Compare
Description:
This Pull requests add a new analyzer for ElevenLabs
Test Cases:
Checklist:
make test-community
)?make lint
this requires golangci-lint)?