apps-android-commons icon indicating copy to clipboard operation
apps-android-commons copied to clipboard

Remove leading and trailing spaces in title

Open NotSoImportant opened this issue 4 years ago • 16 comments

When adding new images through the app it happens that the caption ends with a space. This is then used for title/filename and produces ugly links. Please run a .trim() before uploading.

NotSoImportant avatar Apr 10 '21 14:04 NotSoImportant

Thanks for reporting! Would you have a link to such an uploaded image (with extra spaces)?

nicolas-raoul avatar Apr 21 '21 12:04 nicolas-raoul

I'm new to android development and is willing to handle this issue with my hardest try :) Considering that I'm not that familiar with Android, If I cannot work it out I'll post my failure attempts below.

U81-A avatar Apr 24 '21 08:04 U81-A

@U81-A Thanks! Sure, please let us know how it goes, success or failure :-) Ideally please upload an APK somewhere so that @NotSoImportant can test it.

nicolas-raoul avatar Apr 24 '21 08:04 nicolas-raoul

👍 Is there any procedure how to do test uploads. E.g. to a certain category?

NotSoImportant avatar Apr 24 '21 09:04 NotSoImportant

@NotSoImportant Not really, just upload encyclopedy-worthy pictures that you took :-) If you have none on your phone, you can use some of the pictures I took: https://drive.google.com/drive/folders/1T5wfM16qb78XCvnf1Zunww4neg8BXJj6?usp=sharing

nicolas-raoul avatar Apr 24 '21 10:04 nicolas-raoul

@NotSoImportant Not really, just upload encyclopedy-worthy pictures that you took :-) If you have none on your phone, you can use some of the pictures I took: https://drive.google.com/drive/folders/1T5wfM16qb78XCvnf1Zunww4neg8BXJj6?usp=sharing

Thanks for the shared link, I just went through the developer document and gonna find proper pictures for uploading and testing

U81-A avatar Apr 24 '21 12:04 U81-A

I'm back again, and I went through the code but not quite clear which particular part of the code is responsible for taking in the user's input of the caption :( I also thought that to make the file names and links look nicer, is it possible to only do a trim before uploading the file? (I'll try that and other methods after I found the relevant code block)

U81-A avatar Apr 24 '21 15:04 U81-A

Trimming should be done as early as possible. Please place many breakpoints to see which one gets hit after filling the caption. Good luck! 🙂

nicolas-raoul avatar Apr 25 '21 00:04 nicolas-raoul

See also #4395.

jidanni avatar May 12 '21 01:05 jidanni

@U81-A are u still working on this one ?

4D17Y4 avatar May 15 '21 10:05 4D17Y4

In 3.1.1 (or with potential server changes) the situation now is worse. Upload finally fails, but without any indication why. After retry subsequently fails as well. When re-adding the same text and picture, but this time description not ending with a whitespace it is successful.

NotSoImportant avatar Dec 31 '21 12:12 NotSoImportant

Related: #4676

nicolas-raoul avatar Dec 31 '21 14:12 nicolas-raoul

@NotSoImportant can I know more about this issue ?

samarthasthan avatar Aug 31 '22 18:08 samarthasthan

Sure, what do you want to know?

When using autocomplete to type a title, my keyboard will add a trailing whitespace (which is not obviously recognized by the user). When trying to upload it will fail or hang without any proper error message.

NotSoImportant avatar Aug 31 '22 21:08 NotSoImportant

@NotSoImportant I am interested in working on this issue and would ensure that the string is trimmed before reaching the backend. Please can you assign this issue to me?

shubhamshah14102 avatar Oct 01 '22 07:10 shubhamshah14102

@shubhamshah14102 It is yours, thanks! Please let us know about your progress every few days 🙂

nicolas-raoul avatar Oct 01 '22 10:10 nicolas-raoul

Hi @nicolas-raoul Can I take this up?

bhavanagarlapati avatar Dec 06 '22 08:12 bhavanagarlapati

@shubhamshah14102 Any progress on this?

@bhavanagarlapati Please take one issue at a time. Do not hesitate to come back to this one after sending a pull request for your currently assigned one. :-)

nicolas-raoul avatar Dec 07 '22 08:12 nicolas-raoul

I'm helping someone learn the app, and they're hitting this bug quite often because they inadvertently add a space at the end of the caption. This means they hit the titleblacklist-custom-space issue (because the filename ends up as North Cottesloe beach .jpg):

2023-01-07 09:32:29,004     [ERROR] [file-logging-thread-1] [UploadClient] : Error in uploading file from stash
org.wikipedia.dataclient.mwapi.MwException: ⧼titleblacklist-custom-space⧽

2023-01-07 09:32:29,005     [ERROR] [file-logging-thread-1] [UploadWorker] : java.lang.NullPointerException: The supplied value is null
	at io.reactivex.internal.operators.observable.ObservableOnErrorReturn$OnErrorReturnObserver.onError(ObservableOnErrorReturn.java:80)
	at io.reactivex.internal.observers.BasicFuseableObserver.onError(BasicFuseableObserver.java:100)
	at io.reactivex.internal.observers.BasicFuseableObserver.fail(BasicFuseableObserver.java:110)
	at io.reactivex.internal.operators.observable.ObservableMap$MapObserver.onNext(ObservableMap.java:59)
	at retrofit2.adapter.rxjava2.BodyObservable$BodyObserver.onNext(BodyObservable.java:51)
	at retrofit2.adapter.rxjava2.BodyObservable$BodyObserver.onNext(BodyObservable.java:37)
	at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:44)
	at io.reactivex.Observable.subscribe(Observable.java:12267)
	at retrofit2.adapter.rxjava2.BodyObservable.subscribeActual(BodyObservable.java:34)
	at io.reactivex.Observable.subscribe(Observable.java:12267)
	at io.reactivex.internal.operators.observable.ObservableMap.subscribeActual(ObservableMap.java:32)
	at io.reactivex.Observable.subscribe(Observable.java:12267)
	at io.reactivex.internal.operators.observable.ObservableOnErrorReturn.subscribeActual(ObservableOnErrorReturn.java:31)
	at io.reactivex.Observable.subscribe(Observable.java:12267)
	at io.reactivex.internal.operators.observable.ObservableSingleMaybe.subscribeActual(ObservableSingleMaybe.java:31)
	at io.reactivex.Maybe.subscribe(Maybe.java:4290)
	at io.reactivex.Maybe.blockingGet(Maybe.java:2320)
	at io.reactivex.Observable.blockingSingle(Observable.java:5381)
	at fr.free.nrw.commons.upload.worker.UploadWorker.uploadContribution(UploadWorker.kt:300)
	at fr.free.nrw.commons.upload.worker.UploadWorker.access$uploadContribution(UploadWorker.kt:48)
	at fr.free.nrw.commons.upload.worker.UploadWorker$doWork$2$invokeSuspend$$inlined$map$1$2.emit(Collect.kt:148)
	at kotlinx.coroutines.flow.FlowKt__BuildersKt$asFlow$$inlined$unsafeFlow$3.collect(SafeCollector.common.kt:115)
	at fr.free.nrw.commons.upload.worker.UploadWorker$doWork$2$invokeSuspend$$inlined$map$1.collect(SafeCollector.common.kt:114)
	at kotlinx.coroutines.flow.FlowKt__CollectKt.collect(Collect.kt:30)
	at kotlinx.coroutines.flow.FlowKt.collect(Unknown Source:1)
	at fr.free.nrw.commons.upload.worker.UploadWorker$doWork$2.invokeSuspend(UploadWorker.kt:218)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
Caused by: java.lang.Exception: titleblacklist-custom-space
	at fr.free.nrw.commons.upload.UploadClient.lambda$uploadFileFromStash$3$UploadClient(UploadClient.java:227)
	at fr.free.nrw.commons.upload.-$$Lambda$UploadClient$-xVSLroq3t059tyyfYuDUQukbVk.apply(Unknown Source:4)
	at io.reactivex.internal.operators.observable.ObservableMap$MapObserver.onNext(ObservableMap.java:57)
	... 28 more

2023-01-07 09:32:29,006     [ERROR] [file-logging-thread-1] [UploadWorker] : Upload from stash failed for contribution : North Cottesloe beach .jpg

samwilson avatar Jan 07 '23 01:01 samwilson

Hi, I'm a new contributor here and would like to try my hand at this issue. Can it be assigned to me?

chan-j-d avatar Feb 05 '23 18:02 chan-j-d

@chan-j-d Yes thanks, please let us know about your progress every few days 🙂

nicolas-raoul avatar Feb 06 '23 00:02 nicolas-raoul