admin2: Implement type verification for changing resource settings

Aperta
#564 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
lua
Ambito
backend

Direzione di ricerca

Start by locating admin2’s resource settings update flow and the default resources’ meta.xml entries that define the accept attribute; the issue names no file or test. Check how set() handles values and compare the existing type declarations across resources. Done means settings are validated against consistent supported types and the default resources declare their expected types; the issue also suggests checking whether admin1 has the same problem.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

Is your feature request related to a problem? Please describe.
Recently I've gotten myself in a frustrating situation when I attempted to change a setting of the freeroam resource via admin2. Parts of freeroam stopped working as it expected a table in that setting and even using correct JSON formatting admin2 set the setting as a string. A user shouldn't be able to break parts of default resources like this, especially with no easy way to undo the damage in clear sight. The way set() behaves makes it to neither restarting the resource or changing the setting in the resources meta.xml will actually help you get back to normal.

Describe the solution you'd like
Settings already often have a 'accepted' attribute, however it's not even used consistently within default resources. My desired solution would implement some sort of type checking and update all existing default resources to properly define what type of value they expect.

Describe alternatives you've considered
For the more savvy users converting properly JSON formatted values before applying the setting would be enough, however I believe we can do better.

A 'restore default' button would also be the very least we can offer.

Additional context
The main problem is that there is no standardized nomenclature for the 'accept' attribute. Some use 'bool', others 'boolean', then there are some that list possible values like 'true,false', some will say 'float' or 'int' while others say 'positive number'. It's gonna be impossible to suit every single use perfectly. At the very least the default lua types 'boolean' 'number' 'string' and 'table' should be supported, but I believe there is room to catch some of the commonly used nomenclature variants like 'true/false' and add some basic functionality to be able to verify if a value is a 'positive number', within the range of '0-100' or whether a string is shorter than 32 characters.

[Pending testing] I believe admin1 currently has the same issue.

Lingua principale
Lua
Stelle
185
Fork
180
Merge medio
5g 13h
PR unite (30g)
2

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di multitheftauto/mtasa-resources

Tutte le issue di multitheftauto/mtasa-resources

Issue simili

Altre issue su Lua

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.